www.webdeveloper.com
Results 1 to 4 of 4

Thread: reading value of textbox

  1. #1
    Join Date
    Dec 2012
    Posts
    15

    Question reading value of textbox

    If there are square brackets [] in name of an item in a form how can you use it in javascript?

    Example:

    I have a simple form with several text boxes in it in a PHP page.
    Textboxes are named like this:

    txtbx[1], txtbx[2],.....

    <input type=text size=3 name=txtbx[1] value=5>



    how can I read their value with javascript?

    normally it would be form.txtbx1.value
    but the square bracket (for array in PHP) is causing problem.


    thanks in advance
    Last edited by JayJava; 12-10-2012 at 11:27 PM.

  2. #2
    Join Date
    Dec 2012
    Posts
    97
    You can use form["txtbx[1]"].value to get the value.

  3. #3
    Join Date
    Dec 2012
    Posts
    15

    10000000 thanks

    1000000 thanks iBeZi.
    Last edited by JayJava; 12-11-2012 at 11:22 AM.

  4. #4
    Join Date
    Dec 2012
    Posts
    15
    Update:
    I have tried using this method. Sometimes it works perfectly and sometimes it does not work altough conditions are similar if not identical.
    Are there conditions involved in using this?
    Can you suggest a link or article to do some reading on this topic.
    Thanks in advance

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles