471,316 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

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

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
1 1406


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.

Similar topics

7 posts views Thread by Alex Maghen | last post: by
6 posts views Thread by P. Prosper | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.