PDA

View Full Version : Linking to another page based on the answers given


thasis
09-06-2005, 07:16 PM
I am new to Javascripting. I need to see if there is a way to jump to a page based on the answers to questions asked. If I asked a question, I need to be able to jump to another page based on that specific answer.

For example:

Question: "What is you major"
Answer (choose): Math
Business
Science
English
Other

Based on these answers, I need to be able to jump to a page about "math", "business", "science", "english", or "other".

barryke
09-06-2005, 07:39 PM
I once had the same problem. Try this:
<html>
<head>

<script language="JavaScript">
<!--
function openDir(form) {
window.location =(form.dir.options[form.dir.selected Index].value);
}
// -->
</script>

</head>
<body>

<form name="myform">
<select name="dir" size="1">
<option value="" SELECTED>Choose here..</option>
<option value="http://www.google.com/">Google!</option>
<option value="http://www.yahoo.com/">Yahoo!</option>
<option value="http://www.excite.com/">Excite</option>
</select>
<input type="button" name="button" value="Go!" onclick="openDir(this.form);">
</form>

</body>
</html>
you can mark any one option as SELECTED so it is selected by default.
you can give any option a empty value so you can use it as a label.