
February 28th, 2000, 11:45 AM
|
|
Contributing User
|
|
Join Date: Feb 2000
Location: Englewood, CO
Posts: 30
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
|