Forums

This topic is locked

JavaScript in Forms

Posted 06 Dec 2002 17:29:47
1
has voted
06 Dec 2002 17:29:47 Lee Smith posted:
Is there a way, using JavaScript, of changing the value in a form field when a user clicks on a tickbox?

For Example, If the user clicks on a tickbox (rejected) it needs to change the text in a text field (status) to read "Rejected".

Please Help. This is causing me sleepless nights!!!

Lee Smith

Replies

Replied 08 Dec 2002 11:01:59
08 Dec 2002 11:01:59 Dan The Man replied:
what do you mean "tickbox" ?
rejected as in cancel the form?
status as in why it didn't get subitted?
Replied 08 Dec 2002 12:01:47
08 Dec 2002 12:01:47 Dan The Man replied:
is this what you're looking for
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/JavaScript">
<!--
function Warning(){
if (document.myForm.myCheckBox.checked == true){
document.myForm.myText.value="you have placed a check in the above checkbox";
}
else {document.myForm.myText.value="you didn't placed a check in the above checkbox";
}
}
function Deny(){ //use this function to disable the submit button
if (document.myForm.myCheckBox.checked == true){
document.myForm.mySubmitButton.disabled = false;
}
else {document.myForm.mySubmitButton.disabled = true;
}
}
//-->
</script>
</head>
<body>
<form action="#" method="" name="myForm">
<input name="myCheckBox" type="checkbox" value="" onClick="Deny();Warning()">
My Checkbox <br>
<textarea name="myText" cols="20" rows="5"></textarea>
<br>
<input name="mySubmitButton" type="submit" value="Submit" disabled>
</form>
</body>
</html>
Replied 09 Dec 2002 11:14:12
09 Dec 2002 11:14:12 Lee Smith replied:
Thanks, That was exactly what I was looking for.

Lee Smith

Reply to this topic