Discussions

Web tier: servlets, JSP, Web frameworks: jsp - accessing a form object problem

  1. jsp - accessing a form object problem (1 messages)

    Hello,

    What I want to do is to have a "+" button, so that when you click it, the value of a textfield will be added with one.

    Here my jsp code :
    **************************************************
    td><input type="text" name="quantities(2)" maxlength="10" size="2" value="4">
    <input type="button" name="2" value="+" onclick="document.forms[0].quantities(2).value= document.forms[0].quantities(2).value+ 1">
    ******************************************************

    But when I click my +-button it doesnt work!! Nothing change in the textfield.

    Does anyone see the problem?

    Thanx in advance!

    Olivier

    Threaded Messages (1)

  2. Hi[ Go to top ]

    don't use array notation like quantities(2).
    And then document.forms[0].quantity.value++ will give
    desired result.
    'document.forms[0].quantity.value+ 1' will simply append "1"
    to the string representation of quantity's value.

    regards
    Akash