Object names with square bracket

Discussion in 'Javascript' started by Nalpo, Aug 11, 2004.

  1. Nalpo

    Nalpo Guest

    Hi,
    i want to update several Textboxes by reading the value of another
    Box. For that i use the following small script:

    <form name="form1" method="POST">
    <input type="text" name="xx" value ="1"
    onBlur="document.form1.tex1.value=document.form1.xx.value"><br>
    <input name="tex1" type="text" size=16 maxlength=80 value="1">
    </form>

    Everything works fine, but for my PHP-Script i need square brackets [
    ]. If i try to add them, my Script got an error:

    <form name="form1" method="POST">
    <input type="text" name="xx" value ="1"
    onBlur="document.form1.tex[1].value=document.form1.xx.value"><br>
    <input name="tex[1]" type="text" size=16 maxlength=80 value="1">
    </form>

    Whats wrong?

    Thanks!
     
    Nalpo, Aug 11, 2004
    #1
    1. Advertising

  2. Nalpo

    lallous Guest

    Hello

    This is a common issue.

    Access the named object from javascript as:

    theForm["elementName"].value = xyz .... or
    theForm.elements["elementName"].value = "asdasda";

    Example:

    theForm["tex[1]"].value = xxxxxxxxxxxx................

    HTH,
    Elias
    "Nalpo" <> wrote in message
    news:...
    > Hi,
    > i want to update several Textboxes by reading the value of another
    > Box. For that i use the following small script:
    >
    > <form name="form1" method="POST">
    > <input type="text" name="xx" value ="1"
    > onBlur="document.form1.tex1.value=document.form1.xx.value"><br>
    > <input name="tex1" type="text" size=16 maxlength=80 value="1">
    > </form>
    >
    > Everything works fine, but for my PHP-Script i need square brackets [
    > ]. If i try to add them, my Script got an error:
    >
    > <form name="form1" method="POST">
    > <input type="text" name="xx" value ="1"
    > onBlur="document.form1.tex[1].value=document.form1.xx.value"><br>
    > <input name="tex[1]" type="text" size=16 maxlength=80 value="1">
    > </form>
    >
    > Whats wrong?
    >
    > Thanks!
     
    lallous, Aug 11, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    1,146
    Victor Bazarov
    May 4, 2007
  2. Wabiloo
    Replies:
    1
    Views:
    850
    Martin Honnen
    Jan 25, 2008
  3. Replies:
    1
    Views:
    2,290
    Pavel Lepin
    Mar 14, 2008
  4. winterTTr
    Replies:
    2
    Views:
    370
    winterTTr
    Apr 29, 2009
  5. Asen Bozhilov

    Square bracket and dot notations?

    Asen Bozhilov, Jun 11, 2011, in forum: Python
    Replies:
    4
    Views:
    1,050
    Terry Reedy
    Jun 11, 2011
Loading...

Share This Page