Results 1 to 3 of 3

Thread: Javascript using Spring tags to disable form fields

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    1

    Default 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. #2
    Join Date
    Apr 2005
    Location
    Portland, OR
    Posts
    8

    Default

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

  3. #3
    Join Date
    Aug 2006
    Location
    Gilbert, Az
    Posts
    1

    Default 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

Similar Threads

  1. Replies: 3
    Last Post: Jun 8th, 2010, 03:27 AM
  2. Replies: 6
    Last Post: Sep 24th, 2006, 11:58 AM
  3. Replies: 1
    Last Post: May 14th, 2005, 08:28 PM
  4. Spring code remarks
    By Alarmnummer in forum Architecture
    Replies: 18
    Last Post: Apr 7th, 2005, 07:17 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

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