Closed Thread Icon

Topic awaiting preservation: I cannot see what wrong with this form... Pages that link to <a href="https://ozoneasylum.com/backlink?for=8768" title="Pages that link to Topic awaiting preservation: I cannot see what wrong with this form..." rel="nofollow" >Topic awaiting preservation: I cannot see what wrong with this form...\

 
Author Thread
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 07-22-2003 04:45

Hi, guys. How are you?
Well, I am trying to make form for a couple of hours.
What I have done so far is:

code:
<html>
<head>
<title>Selecting one field with another</title>

<script type="text/javascript">
<!--

function submitIt(carForm){

if(carForm.DoorCt[doorOption].value == "fourDoor" && carForm.sunroof.checked){

alert("The sunroof is only available on the two door mode");
return false;
}

return true;

}

function doorSet(sunroofFiled){

if(sunroofField.checked){

for(i=0; i<document.myForm.DoorCt.length; i++){

if(document.myForm.DoorCt[i].value == "twoDoor"){

document.myForm.DoorCt[i].checked = true;

}

}

}

}

-->
</script>
</head>
<body>
<form onSubmit = "return submitIt(this)" name="myForm">
<input type="checkbox" name="sunroof" onClick="doorSet(this)" value="yes"> Sunroof (two door

only)
<input type="checkbox" value="yes"> Power Window
<br />
<input type="radio" name="DoorCt" value="twoDoor"> Two
<input type="radio" name="DoorCt" value="fourDoor"> Four
<br />
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>



But some reason doesn't work.
What I'd like to do is that if user choose sunroof with Four, alert pops up to prevent user doing so. User only can submit sunroof with Two. Here is my uploaded file.
Many thanks.

Hiroki Kozai

Blaise
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 07-22-2003 05:06

Hi mate,

To start with you have no value set for doorOption

it's a variable you use in your first function

code:
if(carForm.DoorCt[doorOption].value == "fourDoor" && carForm.sunroof.checked)



I asume this should be the option button that is currently in use.

Blaise

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 07-22-2003 05:38

Hi, mate.
Many thanks for tellig me that.
Now I fixed up that point and one spelling mistake.
But still alert box doesn't pup up when it supposed to do.
Here is my new upload file.
Many thanks for sharing your time.
Looking forward to hearing from you.
Cya.

Hiroki Kozai

« BackwardsOnwards »

Show Forum Drop Down Menu