Click to See Complete Forum and Search --> : Help w/ 'Easy' Script


cdsalis75
06-23-2003, 01:43 PM
I'm looking for a fairly simple script that will perform an if/then function. Example: If Gender=Female, then Field1=Her and if Gender=Male, then Field1=His.

Anyone out there know where I could find such a script? Anyone willing to provide a totoal newbie a little guidance on writing this 'simple' script?

Thanks.

Jona
06-23-2003, 01:45 PM
Originally posted by cdsalis75
...[T]hat will perform an if/then function.

Just so you know it's an if/else statement.
Now then, concerning your question, how would the "gender" variable be set? A prompt? Form field?

Jona

cdsalis75
06-23-2003, 02:16 PM
A statement, huh? I'm learning things already. This is exciting!

Anyway, it would be selected from a list/menu. The two options are, as one would expect for gender, Male or Female.

Jona
06-23-2003, 02:43 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head><title>Your Gender</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
<!--
function checkGender(gender, theForm){
if(gender=="male"){
theForm.genderBox.value="You're a dude, dude!";
} else {
theForm.genderBox.value="You're a woman!";
}
}
//-->
</script>
</head>
<body>
<form name="genderForm" action=""><div>
Your Gender:<br>
<select size="1" name="genderSel" onChange="checkGender(this.options[this.selectedIndex].value, this.form);">
<option value="male" selected>Male</option>
<option value="female">Female</option>
</select><br>
<input type="text" name="genderBox"><br>
<input type="button" value="Process Gender" onClick="checkGender(this.form.genderSel.options[this.form.genderSel.options.selectedIndex].value, this.form);">
</div></form>
</body></html>


Jona

cdsalis75
06-23-2003, 02:53 PM
Greatly appreciated.

Thanks Jona!!

Jona
06-23-2003, 03:00 PM
Welcome you are!

Jona