Monday, March 12, 2012

problems with getElementById and Select Box

Hi
I have a problem with a javascript function. I have a select box in my
form called "sale_status" this has two options "pending" and "sold".
When "sold" is selected it should automatically show the "sale_date"
field. The function checkStatus is called onChange().
Problem: my show and hide functions work fine, but when I alert
status.value I get "undefined". can anybody tell me what I'm doing
wrong (the id is definitely correct). I'm sure it's just something
stupid that I've done.
here's my function:
function checkStatus(id){
status = document.getElementById(id);
alert(status.value);
if(status.value=="sold"){
alert('h');
show("sale_date_field");
}
else{
hide("sale_date_field");
}
}
Many Thanks
Ben
oops, sorry, wrong group.

No comments:

Post a Comment