View Single Post
Old 03-13-2005, 07:44 AM   #1 (permalink)
saul
Registered User
 
Join Date: Mar 2005
Posts: 5
saul is on a distinguished road
Sending arbitrary PHP data to HTML forms

Hello,

I am trying to find a quick and generic way of populating arbitrary input type values of an html form from a PHP array. My PHP array is indexed after the form variable names and I want to avoid having to do something like this for each object:

....
User ID: <input type="text" name="user_id" size="20" tabindex="2"
maxlength="127" <?php if(isset($Mydata['user_id'])) echo "value=\"$Mydata['user_id']\"";?> >
.....

Note that the array may have index names that may not exist in the HTML form and the HTML form may have variables that are not set in the array!

Is there a way to preset default browses DOM data from PHP, setting the form values in advanced? or maybe some othe neat trick to do this with javascript? I'm guessing its possible to itterate over all from variables and set thier values by attemting to find them in some javascript array generated by php? any ideas?


Saul.
saul is offline   Reply With Quote