PDA

View Full Version : Text field assigned also to hidden fields



canton
02-03-2009, 07:19 AM
Good Morning,

I want a text field's value to populate/copy on submission to 2 hidden fields value that resides within the same page. Example below

----------------------------

<input type="text" name="county" size="5" maxlength="5" value="55555" />

<input type="hidden" id="age" name="yourcounty" value"" />
<input type="hidden" id="DOB" name="ourcounty" value"" />

-----------------------------

Could this be done with javascript or anyother way maybe

For you information this will be sent to a php file

Please could you advise how this could be possible

Regards

jscheuer1
02-03-2009, 07:28 AM
Can be done. Makes little sense. If it is being submitted via PHP anyway, PHP may just take the value from the first input and use it.

Also, using javascript for something that can be done with no additional server or client side overhead not only compromises the utility of the page, but wastes time/client resources too.

canton
02-03-2009, 02:31 PM
Hello scheuer1,

Thanks for the reply.

This is a temporary fix to a problem i have as the software I'm using is encrypted in such a way that i have to do this until i find a better solution.

Please give me a demonstration how this could be done?

jscheuer1
02-03-2009, 04:06 PM
<form action="#"
onsubmit="var e = this.elements, v = 'value', n = 'county';
e['your'+n][v] = e['our'+n][v] = e[n][v]; return true;">
<input type="text" name="county" size="5" maxlength="5" value="55555">
<input type="hidden" id="age" name="yourcounty" value"">
<input type="hidden" id="DOB" name="ourcounty" value"">
<input type="submit" value="Go!">
</form>

But, as I was hinting at, with javascript disabled, this will not work. Also, since the value of "county" is already known in the PHP submit environment, it would be easier and better to set whatever you are currently setting from "yourcounty" and "ourcounty" from "county". The result would be the same, no javascript required.

canton
02-03-2009, 04:41 PM
Jhon
Thank you for your time and patience:D. I will get on the case with my project in the morning.

regards

canton
02-13-2009, 05:21 AM
Hay Jhon,

Im trying to create some amendments within some form fields as the files that need to be adjusted in the php scipts are encrypted.

So im forced to use a work around. I'll explane best what i want to do via the very simple php script below

first the form fields (all field names are related to there php objects)


----------------------

<--! this is the "title" field -->
<td><input type="text" name="title" style="width: 100%" value="we are her" /></td>

<--! this is the "categories" field -->
<td><select name="categories[]" id="categories" multiple="multiple" class="inputbox" size="7" ></td>

<--! this is the "Number of Bedrooms" field -->
<td ><select name="fields[39]" id="fields39" size="1" style="width:100%"><option value="" >- Number of Bedrooms -</option>

<--! this is the "Property Type" field -->
<td ><select name="fields[38]" id="fields38" size="1" style="width:100%"><option value="" >- Property Type -</option>

<--! this is the "City" field -->
<td><input type="text" size="20" name="fields[18][city]" value="london"/> </td>

<--! this is the "state" field -->
<td align="right"><input type="text" size="20" name="fields[18][state]" value=""/> </td>

<--! this is the "country" field -->
<td align="right"><input type="text" size="20" name="fields[18][country]" value=""/> </td>

-----------------------------

now the php amendment.

-----------------------------

$prefix = 'my house ';
$noRooms = ' ' . $object->Number_of_Bedrooms;
$proType = ' ' . $object->Property_Type;
$city = ' ' . $object->City
$county = ' ' . $object->state
$country = ' ' . $object->Country

$object->title = $prefix . $noRooms . $proType . $city . $state . $country;

------------------------------

and for the second adjustment

-----------------------------

$object->title = $object->country;

-----------------------------

how could i have the same disired effect in Javascript or maybe theres another solution?

Thanks in advanced :)