(可能)在這裏簡單的jQuery問題。我正在使用jQuery UI對話框,並且正在確認。基本上,當用戶選擇某個選項(結合其他情況)時,我希望能夠將它們發送回最後一次選擇的選項,或者如果我不能這樣做,那麼這是默認選項。如何從一個選擇選項發送到另一個選項?
這個選項沒有「selected」屬性,這本來就是我的例子。有沒有辦法做到這一點?
這裏是JS:
alert('hey')
if (document.frm.notNull.checked == true) {
// This is where it ends!
if ($('input[name=valueTextField]').length > 1) {
$('#dialog p').empty();
$('#dialog p').html("You're going to lose your stuff if you do this. You sure you want to?");
$('#dialog').dialog({
autoOpen: true,
width: 600,
modal: true,
buttons: {
"<spring:message code='dialogBox.cancelConfirmation.YES'/>": function() {
$(this).dialog("close");
$("#bottom").css('visibility', 'visible');
$('.edit-new').css('visibility', 'hidden');
$('.edit-trash').css('visibility', 'hidden');
// if table has more than one row, delete the rest.
deleteExtraRows('valueTable');
return true;
},
"<spring:message code='dialogBox.cancelConfirmation.NO'/>": function() {
$(this).dialog("close");
// Need to revert the user back to where they came from here.
$('#control[value=1]').attr('selected', true);
// return false;
}
}
});
} else {
$("#bottom").css('visibility', 'visible');
$('.edit-new').css('visibility', 'hidden');
$('.edit-trash').css('visibility', 'hidden');
// if table has more than one row, delete the rest.
deleteExtraRows('valueTable');
return true;
}
}
這是HTML(被動態渲染):
<div class="lbl">
<label>Control</label>
</div>
<select style="margin:0 0 0 8px; left:15px; position:relative;" name="control"
id="control" onChange="checkTableVisibility();">
<option value=1>Check Box</option>
<option value=0>Dropdown Menu</option>
<option value=3>Radio Button</option>
<option value=2 selected="selected">Text Box</option>
</select>
你有任何代碼或樣品來證明你想做的事......它有點混亂,以從上述文字看着辦吧.. – Scorpio
比較遺憾的是什麼,添加了一些代碼,看它是否會幫助!感謝您的關注! – streetlight