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

  • Javascript using Spring tags to disable form fields

    Hi,
    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
    <Script>
    function Enable(this){
    document.FormName.referenceHistories[0].fullName.disabled = false;
    }
    </Script>

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

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

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

    Comment


    • #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) {
      form.action.disabled=true;
      submitted = true;
      form.submit();
      }

      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>
      </spring:bind>

      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.

      thanks

      Comment

      Working...
      X