Option Creation and selecting not working in IEx
Can someone tell me why this snippet of code does not work in any version of IE yet works fine in Firefox and Chrome?
- <?
require_once("db/db.class.php");
$db = new db_class;
$classId = intval($_GET['classId']);
$selSub = intval($_GET['selsubclassId']);
$d = $db->connect();
$q = "SELECT sub_class, short_name FROM material_classes WHERE class = '".$classId."' AND sub_class != '0' AND sub_sub_class = '0'";
$r = $db->select($q);
$options = "<select name=\"sub_class\" id=\"sub_class\" onChange=\"getSSC($('#itemclass option:selected').val(),$('#sub_class option:selected').val());getMaterials('default',$('#itemclass option:selected').val(),$('#sub_class option:selected').val(),0,$('#p1').is(':checked'));\">\n";
while ($row = $db->get_row($r,'MYSQL_ASSOC')) {
$options .= "<option value=\"".$row['sub_class']."\"";
if ($row['sub_class'] == $selSub) {
$options .= " \"selected\" ";
}
$options .= ">".$row['short_name']."</option>\n";
}
$options .= "</select>\n";
echo $options;
?>
It should be creating a set of options for a the select statement with id "sub_class", which it does. However, it should also be setting the selected option to the value I pass as 'selsubclassId', which only seems to work in FF or Chrome. In IE, the selected item always defaults to the first option. It's pretty basic PHP and jQuery. Is IE that stupid? Do we have a workaround?