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 6 of 6

Thread: re-enabling

  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts

    re-enabling

    after i disabled a <input type="button"> I want to re-enable it so it can be clicked again. I am disabling the button by doing this.

    test() {
    document.form[0].tes.disabled=true;
    }
    <input type="button" name="tes" onClick="test()">

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this should make the button toggle the input between enabled and disabled...

    function not_test() {
    document.forms[0].tes.disabled=(document.forms[0].tes.disabled)?false:true;
    }

    I would not use 'test' as the function name - that is a built-in function in javascript
    ----edit----
    There was a few typos, forms[] not form[]
    ALso I'm just realizing that you want to enable and disable the button that you actually click on to call the function... don't think this will work.
    Last edited by boywonder; 09-19-2002 at 01:32 AM.

  • #3
    umm
    umm is offline
    Regular Coder
    Join Date
    Sep 2002
    Location
    Antipodes
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi chrismiceli,
    what condition do you want to reach that enables the button?

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here is my script i would assume the stuff in bold would make the disabled function become enabled but it doesn't.

    Code:
    <html> 
    <head> 
    <title>test</title> 
    <script language="javascript">
    function stats() {
    spd = prompt("Please enter your speed", "Enter it here");
    }
    function di() { 
    var ran_num = Math.round(5*Math.random()) + 1; 
    document.form1.res.value = ran_num; 
    	if (document.form1.res.value > 3) {
    var ran_num0 = Math.round(5*Math.random()) + 1;
    document.form1.res0.value = ran_num0}
    	else document.form1.res0.value = "0";
    document.form1.put.disabled=1;
    }
    function dmg(v1) {
    --spd
    var fh = v1;
    document.form1.foehealth.value = fh - document.form1.res0.value
    	if (spd <= 0) {
    document.form1.put.disabled=1;
    document.form1.hit.disabled=0;}
    document.form1.res.value = "";
    document.form1.res0.value = "";
    }
    </script>
    </head> 
    <body onLoad="stats()"> 
    <form name="form1"> 
    Enemy's Health:<br>
    <input type="text" name="foehealth"  size="12" value="500"><p>
    <input type="text" name="res" size="2" value="">
    Roll to see if you will hit.<br>
    <input type="text" name="res0" size="2" value="">
    You will deal this much damage.<br>
    <input type="button" name="put" value="Roll Dice" onClick="di()"><p> 
    <input type="button" name="hit" value="Attack" onClick="dmg(document.form1.foehealth.value)"> 
    </form> 
    </body> 
    </html>

  • #5
    umm
    umm is offline
    Regular Coder
    Join Date
    Sep 2002
    Location
    Antipodes
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what it the aim of this script?

  • #6
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you like rpgs


    I got it working thanx anyway though


  •  

    Posting Permissions

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