我有一个功能,当用户点击按钮时,我会设置cookie值。
在change事件中,我从选择框中调用两个方法。这个函数调用正确,工作正常。但当我从下面的jquery函数调用这两个函数时,我遇到了问题。
<select NAME="the_menu" size="1" id="Item" onChange="UpdateUnitMenu(this, document.form_A.unit_menu); UpdateUnitMenu(this, document.form_B.unit_menu)">
如果有任何cookie以“语言”的名义存在,我想调用相同的方法。
two函数基本上基于对第一个值的选择来填充另外两个下拉选择框值。
我的表单
<form name="property_form" >
<select NAME="the_menu" size="1" id="Item" onChange="UpdateUnitMenu(this, document.form_A.unit_menu); UpdateUnitMenu(this, document.form_B.unit_menu)"> <optgroup label="Select Any One Type"> </optgroup> </select>
<input type="button" id='continue' value="Save as default value"/>
</form>
我的功能
<script>
$(document).ready(function(){
$('#continue').click(function() {
var singleValues = $("#Item").val();
$.cookie("language", singleValues);
})
alert($.cookie('language'));
$('#Item').val($.cookie('language')).attr('selected', true);
if($.cookie('language')!=null)
{
var th=$.cookie('language');
UpdateUnitMenu(th, document.form_A.unit_menu);//trying to call first function
UpdateUnitMenu(th, document.form_B.unit_menu);//trying to call first function
}
});
</script>