Announcement Announcement Module
Collapse
No announcement yet.
How to call a <form:input> from javascript? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to call a <form:input> from javascript?

    Hi,

    I have a form input that i would like to set the "disabled" to true when i call javascript function

    Here's my textfield
    <form:input path="testPath" disabled="true" id="testID"/>

    the checkbox calling the javascript function
    <form:checkbox path="checkBoxPath" id="checkbox1" onclick="enableField()"/>

    Here's the javascript
    <script language="javascript">
    function enableField()
    {
    alert("HERE");
    if (checkbox1.checked == true) //Find out if the checkbox is checked.
    {
    alert("CHECKED");
    testID.disabled = false;
    }
    else
    {
    alert("NOT CHECKED");
    }
    }
    </script>

    Somehow the script doesn't seems like checking if checkbox1.checked == true

    Can someone tell me how can I check my checkbox1 ?


    Thanks,

  • #2
    Hi geek.shrek

    pls use code tags

    i suggest read carefully javascript documentation

    first
    Code:
    Somehow the script doesn't seems like checking if checkbox1.checked == true
    of course, you must call elements in a form by its id, your way is wrong

    second
    Code:
    testID.disabled = false;
    thats wrong, again you must call elements in a form by its id, and that way of change the disabled = false; is wrong

    i suggest see javascript documentation and for js support and other things
    see this forum
    http://webdeveloper.com/

    regards

    Comment

    Working...
    X