#1
  1. PHP Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    England
    Posts
    163
    Rep Power
    13

    Angry Javascript and inputting with PHP


    I'm trying to create input boxes on the fly by using php variables:

    PHP:

    <INPUT TYPE = "HIDDEN" NAME = "status[<?=$i?>]" value = "<?=$status[$i]?>">

    so that will create:

    <INPUT TYPE = "HIDDEN" NAME = "status[0]" value = "collapse">
    <INPUT TYPE = "HIDDEN" NAME = "status[1]" value = "collapse">

    then i'm trying to set the value to something else using:

    onclick = "document.all['tree'].status[<?=$i?>].value='expand';

    tree is the name of the form.

    which is giving an output of:

    onclick = "document.all['tree'].status[1].value='expand';

    but i'm getting a an error on page dialog saying:

    'document.all.tree.status.0 is null or not an object'

    any ideas

    basically i'm trying to create an IE and netscape friendly tree control which is all dynamically created using an array passed.


    Thanks

    Andy
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    First off, wrong forum. There's no java involved. The html/css/javascript forum is the one you want.
    Second, javascript thinks you're trying to access an array with status[1] in your onclick event, but actually trying to access "status[1]". I think you're probably going to have to rename your inputs to status0, status1, etc, then compensate in your php. The other option would be to address the tags by an index value, rather than name. For ie5+ and nn6 you could use document.getElementsByTagName( 'input' ).item( index_value );

IMN logo majestic logo threadwatch logo seochat tools logo