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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Esben Rune Hansen

    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='multip art/form-data'>
    <input type=hidden name='data[3]' value='default :-('>
    <script language='javas cript'>
    document.edit_f orm.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='multip art/form-data'>
    <input type=hidden name='data3' value='default :-('>
    <script language='javas cript'>
    document.edit_f orm.data3.value = 'not default :-)';
    </script>
    <input type='submit'></form>
    ----------------------------------------------------------


  • Martin Honnen

    #2
    Re: javascript accessing i.e &quot;data[3]&quot; in a form



    Esben Rune Hansen wrote:

    [color=blue]
    > 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?[/color]

    Check the FAQ:

    there you find



    --

    Martin Honnen


    Comment

    Working...