PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 27th, 2000, 02:21 AM
janaka janaka is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 3 janaka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0

...in a lengthly form, is it possible to use PHP3 to automatically fill form fields with data that has already been entered into a previous place on the same form? ...or from a previously filled out form?
...likewise, is it possible to perform a math calculation on a number entered into a field and have the result automatically defaulted to another subsequent field?

...answers to these questions will be much appreciated.

Reply With Quote
  #2  
Old February 28th, 2000, 02:49 AM
firepages's Avatar
firepages firepages is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: Perth West Australia
Posts: 757 firepages User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 18 m 32 sec
Reputation Power: 14
Not sure if it can be done on the same page without re-sending the page to itself - but you can span 2 or more pages & php will remember the values from all form inputs - be careful not to use the same name for values in different pages as the second will overwrite the first.
Try the example below - create 2 pages one called thisform.php3


<html>
<body>
<form method=post action="page2.php3">
enter number:<input type="text" name="num0" ><br>
enter number:<input type="text" name="num1" ><br>
enter text:<input type="text" name="yourtext" ><br>
<input type="submit" name="submit">
</form></html>

and another called page2.php3 -

<html>
<body>
<form method=post action="thisform.php3">
num0 + num1:<input type="text" name="newnum0" value="<?php echo $num0 + $num1?>"><br>
num1 x num0:<input type="text" name="newnum1" value="<?php echo $num0 * $num1?>"><br>
<input type="text" name="newtext" value="<?php echo $yourtext; ?>"><br>
<input type="submit" name="submit">
</form></html>

just look at the code to see how it works.


------------------
Simon Wheeler
FirePages -DHTML/PHP/MySQL

Reply With Quote
  #3  
Old February 28th, 2000, 11:45 AM
TroutMask TroutMask is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Englewood, CO
Posts: 30 TroutMask User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
I'm not to clear on your first question; I can interpret it two ways, so I'll answer both:

If you want the contents of a text field to be automatically entered into another text field on the same page as the user enters data into the first field, you'll have to use JavaScript (or similar)...I use a function document.onkeyup to check where a user is entering information and act on other form fields accordingly. You could use document.onkeyup to see on what form field (if any) the current focus is and change some other field based on that.

To pass information from one form to another, have PHP print the values of the form elements as value="(value)" in the form elements of the new page.

Like this:

...
<INPUT TYPE='text' value='
<?
print "$stored_value"; // (or whatever)
?>
' LENGTH='10' MAXLENGTH='10'>
...etc...

That will put in a text box with the value of $stored_value as it's default value.

For the calculator problem, you'll use Javascript as described above, catching the onkeyup (or another onkey event) and performing your calculations on the fields of interest.

The primary difference between handling activities via Javascript or PHP is the fact that Javascript can be used on the client side while PHP is strictly server side. That is, if you want your page to change without the user connecting to a server some way (like submitting a form or clicking a URL), you'll have to use a client-side scripting language like Javascript. If you want anything to happen after the user clicks submit or a URL, you can use PHP to process the request and send back HTML customized to your needs, including building custom Javascript code for the client. It sounds like you are primarily trying to change the contents of your site without the user submitting a form or clicking a URL. PHP will do nothing on the client side, therefore you need a client-side scripting language like Javascript.

-TM

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > defaulting data in form fields

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap