By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

javascript accessing i.e "data[3]" in a form

P: n/a
Hi

I am working on a PHP-script and need javascript to set the value of a
hidden field in a form. This field happens to be an entry in an array
data[3] according to my example. How can I do this?

Below is listet two PHP-pages: one that doesn't work (to my dismay), and
another that does work, but do not use an array entry in the hidden field.

Thanks

Esben

---------- Doesn't work as planned -----------------
<? print "data[3]=".$data[3]."\n";?>
<form action='<?$PHP_SELF?>' name='edit_form' method=post
enctype='multipart/form-data'>
<input type=hidden name='data[3]' value='default :-('>
<script language='javascript'>
document.edit_form.data[3].value = 'not default :-)';
</script>
<input type='submit'></form>
----------------------------------------------------------

----------Doesn't use arrays----------------------------
<? print "data3=".$data3."\n";?>
<form action='<?$PHP_SELF?>' name='edit_form' method=post
enctype='multipart/form-data'>
<input type=hidden name='data3' value='default :-('>
<script language='javascript'>
document.edit_form.data3.value = 'not default :-)';
</script>
<input type='submit'></form>
----------------------------------------------------------
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Esben Rune Hansen wrote:

I am working on a PHP-script and need javascript to set the value of a
hidden field in a form. This field happens to be an entry in an array
data[3] according to my example. How can I do this?


Check the FAQ:
http://jibbering.com/faq/
there you find
http://jibbering.com/faq/#FAQ4_25
http://www.jibbering.com/faq/faq_not...kets.html#illc

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.