maxelcat
09-30-2008, 02:33 PM
Dear All
I want to get the value from a select option in a form. It works in FF but not in IE7 which just returns a blank alert window.
I suspect I am doing something pretty stupid!
Any ideas please!
Here's the html
<script src="pafForm.js" type="text/javascript"></script>
<title>Untitled Document</title>
</head>
<body>
<form action="contact.html" name="pafEnquiries" method="post">
<select id="projectType">
<option>Please select</option>
<option>Commercial</option>
<option>Residentail</option>
<option>Industrial</option>
</select>
</form>
and here's the js
window.onload = initForm;
function initForm(){
document.getElementById("projectType").selectedIndex=0;
document.getElementById("projectType").onchange=populateApplication;
}
function populateApplication(){
var edNum = document.getElementById("projectType").selectedIndex;
var edValue = document.getElementById("projectType").options[edNum].value;
alert (edValue);
}
I want to get the value from a select option in a form. It works in FF but not in IE7 which just returns a blank alert window.
I suspect I am doing something pretty stupid!
Any ideas please!
Here's the html
<script src="pafForm.js" type="text/javascript"></script>
<title>Untitled Document</title>
</head>
<body>
<form action="contact.html" name="pafEnquiries" method="post">
<select id="projectType">
<option>Please select</option>
<option>Commercial</option>
<option>Residentail</option>
<option>Industrial</option>
</select>
</form>
and here's the js
window.onload = initForm;
function initForm(){
document.getElementById("projectType").selectedIndex=0;
document.getElementById("projectType").onchange=populateApplication;
}
function populateApplication(){
var edNum = document.getElementById("projectType").selectedIndex;
var edValue = document.getElementById("projectType").options[edNum].value;
alert (edValue);
}