我在下面的html php表单中选择下拉框,我已经添加了30天使用PHP下拉,现在我想要从我添加jquery为显示选择它正在工作,但以前选择的值不删除它显示以前的值请在我创建的表单下面给我解决方案,并在显示中选择显示的jquery
<form name = "form1" id = "form1" action = "#" method = "post">
<div id="myform">
<select name = "DropDownList1" id = "DropDownList1">
<?php
$myVar="";
for($i=1;$i<=30;$i++){
?>
<option value="<?php echo $i; ?>" id="weeks"> <?php echo $i;?> <?php if($i==1){ echo "Day";} else{echo "Days";}?></option>
<?php }?>
</select> <!-- finish the form in html -->
</div>
<select name = "DropDownList2" id = "DropDownList2">
<option value="1" <?php if ($myVar==1) echo 'selected="selected"';?>>First Week</options>
<option value="2" <?php if ($myVar==2) echo 'selected="selected"';?>>Second Week</options>
<option value="3" <?php if ($myVar==3) echo 'selected="selected"';?>>Third Week</options>
<option value="4" <?php if ($myVar==4) echo 'selected="selected"';?>>Fourth Week</options>
</select>
<input type="submit" value="go" name="go">
</form>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
jQuery( document ).ready(function() {
jQuery( "#myform #DropDownList1" ).change(function() {
var selbox= jQuery(this).val();
jQuery("#DropDownList1 option[value='" + selbox + "']").attr("selected","selected");
});
});
</script>