Reply
Set Hidden Input, that is an array
Old 02-08-2008, 02:43 PM Set Hidden Input, that is an array
Average Talker

Posts: 16
Location: Canada
Hi,

This may be a really simple solution; I'm not sure, as I'm new to javascript.

I have a form with a bunch of hidden inputs, that are generated based on a MYSQL database (a couple hundred entries). For example:

PHP Code:
<input type=hidden name=mass[123value=0
When the user inputs a value into a text input and clicks a button, I want the page to store the value of the text input to the hidden input. I can get the page to forward the variable, containing the number of the field (eg: 123), but can't seem to get it to alter the input.

Currently I have:

PHP Code:
function addMass(id)
{
    var 
form document.recipe.mass[id];
    
form.value document.formMass.mass.value;
    

Does anyone know a) why this isn't working and b) how I can change it so it does work?

Thanks in advance; any help is appreciated.
Scott
scott_g is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 02-08-2008, 03:43 PM Re: Set Hidden Input, that is an array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Code:
function addMass(id)
{
var idFieldName = "mass" + id;
var form = document.recipe[idFieldName];
form.value = document.formMass.mass.value;
}
Try that. If that doesn't work for you, then we'd have to see your code.

ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-08-2008, 09:25 PM Re: Set Hidden Input, that is an array
Average Talker

Posts: 16
Location: Canada
I seem to have solved it after I played around with the code a little more. The final function I came up with was:

Code:
function addMass(id)
{
    var form = document.getElementById("mass"+id);
    form.value = document.formMass.mass.value;
    
}
It isn't in an array, but I can use the php to extract the information from the $_POST[mass#] variable.

Thank you very much for your response; it helped a great deal and is very much appreciated.

Thanks again,
Scott
scott_g is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Set Hidden Input, that is an array
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.32970 seconds with 12 queries