Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 19
Location: Canada
Trades: 0
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
 
 
Register now for full access!
Old 02-08-2008, 04:43 PM Re: Set Hidden Input, that is an array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
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.

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-08-2008, 10:25 PM Re: Set Hidden Input, that is an array
Average Talker

Posts: 19
Location: Canada
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.26045 seconds with 12 queries