Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS controlled variables not being posted down to servlet

    Hi All

    I've created a html page that basically is a way of controlling a user's use of a web application. The page allows the user to limit the uses to say 30 per month, or alternatively an unlimited amount.

    So the page could consist of a html "input" text box, and a check box, where ticking the check box indicates unlimited use.

    That basically is what I wanted the page to do. But if you are using unlimited then the text box is no longer valid. So I created some javascript that disables the text box whenever the checkbox is ticked.

    <div id="appUsageId"><input type="text" name="appUsage"></div>

    So when the check box is ticked JS replaces the text above in the div tag with:
    <div id="appUsageId"><input type="text" name="appUsage" DISABLED></div>

    So when you untick, it reverts back. However my problem occurs when you tick on the box, then untick it, enter a value in the box and click submit. For some reason the "appUsage" parameter is not posted down to the servlet...

    However if you don't tick the box ( so don't invoke JS ) then the value is posted down fine.

    I honestly haven't a clue why this is happening. Does anybody have any ideas??

    I have included the basic javascript below.

    Any help you can give would be fantastic. Thanks a million

    Cheers
    Glenn





    var unlimUses=false;
    function tickedUnlimitedUsesBox(){
    var textBoxValue=""
    if(unlimUses){
    unlimUses=false;
    textBoxValue='<input type="text" name="appUsage" value ="0">';

    }else{
    unlimUses=true;
    textBoxValue='<input type="text" name="appUsage" DISABLED value ="Unlimited">';
    }
    document.getElementById("appUsageId").innerHTML = textBoxValue;
    }

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You did not provide enough code to even run your script and your post is too confusing to bother to try to interpret and replicate your intentions... But disabled form elements are not submitted with the form...

    If you need more help... Using [code]...CODE HERE... [/code] tags, post enough of the HTML and javascript to run your codes...

    .....Willy


  •  

    Posting Permissions

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