Announcement Announcement Module
No announcement yet.
Javascript using Spring tags to disable form fields Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript using Spring tags to disable form fields

    Here's my problem.
    My jsp page have springframework binding. I have 2 radio buttons "Yes" & "No". What I would like to do is when the user selects "No" , I would like to disable all my Form Fields for that page so he cannot input anything into these fields.
    Javascript I've written is as follows
    function Enable(this){
    document.FormName.referenceHistories[0].fullName.disabled = false;

    Within the Form my input fields are binded in the following format
    <spring:bind path = "comand.referenceHistories[0].fullName>
    <Input type = "text"......>

    The javascript throws errors saying object is either null or no value exists for that object.
    Any help is appreciated.

  • #2
    Try View: Source in your web browser. What HTML do you see for the <spring:bind> tag?


    • #3
      Script issue

      I would normally start a new thread for this but I am having the exact same issue and the gentleman might benefit from my placing my situation here as well.

      I am attempting to avoid repetitious postbacks by multiple clicks with a button that submits a text area to a controller. The original fix was to create a small java script function that would disable the button after the first click:

      var submitted = false;
      function submitOnlyOnce(form){
      if (submitted) {
      alert("Form already submitted, one moment please");
      return false;
      if (!submitted) {
      submitted = true;

      however, upon adding this to the form tag:

      <form method="post" action="#grid" onSubmit="submitOnlyOnce(this);return;false">

      I recieved the same null issue when trying to bind the text area set up as shown:

      <spring:bind path="command.keywordText">
      <textarea name="<c: out value="${status.expression}"/>" rows=5 class=form_field3></textarea>

      hope this helps us uncover the issue. I am wondering if it has to do with post order. Perhaps the form object is being taken off of the post when Spring runs through the command words and the script is running first, effectively making the reference null before spring can handle it. Just speculation though.