drop down box, onchange envokes javascript

Dell / Lap top
October 30, 2009 at 16:45:41
Specs: Windows XP, pentium 4
Hi guys,

I have been toying with this for a while tonight. I am trying to use the onchange event to send an id to a javascript function that will fill in the hidden value of an input field and pen a hidden div if the id is a certain number. I will post the code below.

Here is the drop down box:

<tr><td align="right">Category</td><td><select name="category" id="category" onchange="catter(this.value)">
<?php
$con = conDB();
$getCats = mysql_query("SELECT * FROM categories WHERE class='media' ",$con);
while($cat = mysql_fetch_array($getCats)){
if ($cat['name']!="All") {
?><option value="<?= $cat['id'] ?>" <?php if($photo->category==$cat['id']) { ?> selected <?php } ?>><?= $cat['name'] ?></option>
<?php }
} ?></select></td></tr>

here is the javascript function...

<script language="JavaScript">
<!--
function catter(cat)
{
document.getElementById("cattyper").value=cat;

switch (cat)
{
case 60:
document.getElementById("artboxa").style.display = "block";
break;
case 2:
document.getElementById("artboxa").style.display = "block";
break;
case 1051:
document.getElementById("artboxa").style.display = "block";
break;
case 1017:
document.getElementById("artboxa").style.display = "block";
break;
case 25:
document.getElementById("artboxa").style.display = "block";
break;
case 26:
document.getElementById("artboxa").style.display = "block";
break;
case 7:
document.getElementById("artboxa").style.display = "block";
break;
case 5:
document.getElementById("artboxa").style.display = "block";
break;
case 1032:
document.getElementById("artboxa").style.display = "block";
break;
case 4:
document.getElementById("artboxa").style.display = "block";
break;
default:
document.getElementById("artboxa").style.display = "none";
}
}
//-->
</script>

its weird because if i click browser back and then browser forward it sometimes works. Im at a loss. Any help would be greatly appreciated.


See More: drop down box, onchange envokes javascript

Report •


#1
November 20, 2009 at 23:11:54
Hai

I can hep you. I used to these kind of passing values to hidden fields just onclick / onchange. Its easy dude. Actually you are almost done. I can help you with this issue. for further support mail me haijerome@gmail.com


Report •
Related Solutions


Ask Question