So, I’ve gone and messed something up. This onchange worked fine yesterday – don’t recall doing any changes – the same onchange works in other parts of the site – and yet I have been staring at this for over an hour trying to figure out what stupid syntax or stupid whatever error I’m making that is preventing this from firing. I’m sure it’s something simple and I’m just looking too hard…
Here is the html for the relevant parts of the form:
[CODE]
<form enctype=”multipart/form-data” action=”<?php echo $_SERVER[PHP_SELF];?>” method=”POST”>
<select name=”maincat_id” onchange=”reload(this.form)”>
<option value=”0″>Select Main Category</option>
<option value=”4″>Employment</option>
<option value=”6″>For Rent</option>
<option value=”5″>Garage/Yard/Estate Sales</option>
<option value=”1″>Housing/Property</option>
<option value=”2″>Items For Sale</option>
<option value=”3″>Services</option>
<option value=”7″>Wanted</option></select>
<input type=”submit” name=”submit_ad” id=”submit_ad” value=”Submit Ad” />
</form>
Here’s ALL of the javascript in the header – no other JS on the page.
[CODE]
<SCRIPT language=”JavaScript”>
function reload(form){
var val=form.maincat_id.options[form.maincat_id.options.selectedIndex].value;
self.location=’submitad.php?maincat_id=’ + val ;
}
function reload2(form){
var val=form.maincat_id.options[form.maincat_id.options.selectedIndex].value;
var val2=form.subcat1_id.options[form.subcat1_id.options.selectedIndex].value;
self.location=’submitad.php?maincat_id=’ + val + ‘&subcat1_id=’ + val2 ;
}
function reload3(form){
var val=form.maincat_id.options[form.maincat_id.options.selectedIndex].value;
var val2=<?php echo $_GET[ad_id];?>;
self.location=’edit.php?&ad_id=’ + val2 + ‘&maincat_id=’ + val ;
}
function reload4(form){
var val=form.maincat_id.options[form.maincat_id.options.selectedIndex].value;
var val2=form.subcat1_id.options[form.subcat1_id.options.selectedIndex].value;
var val3=<?php echo $_GET[ad_id];?>;
self.location=’edit.php?&ad_id=’ + val3 + ‘&maincat_id=’ + val + ‘&subcat1_id=’ + val2 ;
}
function reload5(form){
var val=form.maincat_id.options[form.maincat_id.options.selectedIndex].value;
var val2=<?php echo $_GET[ad_id];?>;
self.location=’ads.php?&submit=TRUE&ad_id=’ + val2 + ‘&operation=edit&maincat_id=’ + val ;
}
function reload6(form){
var val=form.maincat_id.options[form.maincat_id.options.selectedIndex].value;
var val2=form.subcat1_id.options[form.subcat1_id.options.selectedIndex].value;
var val3=<?php echo $_GET[ad_id];?>;
self.location=’ads.php?&submit=TRUE&ad_id=’ + val3 + ‘&operation=edit&maincat_id=’ + val + ‘&subcat1_id=’ + val2 ;
}
</script>
What it’s supposed to do: changing selection on first <select> populates values for second <select>.
What it does: Changing the selection in the select box does nothing – doesn’t even try to reload the page.
I can give you the rest of the code if you want it, but since the onchange doesn’t even TRY to reload the page, I’m not sure it’s relevant.
This particular <select> box calls function: reload(form). I have the same <select> box on other pages of the site (where you edit all the information input on THIS page) calling reload2(form) and so on… and it works fine.
So I’m hoping someone can give me some debug ideas: “Did you check this?” “Did you forget this?” etc.. Obvious stuff that has escaped me today.
Browser: Doesn’t work in FF or IE7
link: [url]http://www.centexconnect.com/test/actions/submitad.php[email][email protected]