...

View Full Version : re-enabling



chrismiceli
09-19-2002, 12:59 AM
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()">

boywonder
09-19-2002, 01:27 AM
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.

umm
09-19-2002, 02:33 AM
Hi chrismiceli,
what condition do you want to reach that enables the button?

chrismiceli
09-19-2002, 03:59 AM
here is my script i would assume the stuff in bold would make the disabled function become enabled but it doesn't.



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

umm
09-20-2002, 01:26 AM
what it the aim of this script?

chrismiceli
09-20-2002, 02:48 AM
http://codingforums.com/showthread.php?threadid=6493


I got it working thanx anyway though



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum