0
希望我现在清楚我的问题。JavaScript代码工作在窗体上加载
我有一个分享点列表,其中我隐藏/显示基于另一个字段中数据的某些字段(是/否下拉列表)。举例来说,我有第1列是和无下拉菜单。如果此列1中的值选择为Yes,则应显示四列A,B,C和D.如果第1列为否,则应隐藏A,B,C和D.它在表单加载时工作良好。
但是,当表单在保存时返回错误时,即使依赖字段仍然为“是”,但在依赖字段中选择“是”时显示的字段将被隐藏,并且必须切换在是和否选择之间再次显示字段。
下面是我用过的代码。
<script src="https://code.jquery.com/jquery-1.7.2.min.js" type=text/javascript></script>
<script type="text/javascript">
// Execute the following JavaScript after the page has fully loaded, when it's ".ready"
$(document).ready(function() {
$('nobr:contains("Question 1")').closest('tr').hide();
$('nobr:contains("Question 2")').closest('tr').hide();
$('nobr:contains("Question 3")').closest('tr').hide();
$('nobr:contains("Question 4")').closest('tr').hide();
//Show/hide columns based on Drop Down Selection
$("select[title='Do you know Java Scripting']").change(function() {
if ($("select[title='Do you know Java Scripting']").val() != "Yes") {
$('nobr:contains("Question 1")').closest('tr').hide();
$('nobr:contains("Question 2")').closest('tr').hide();
$('nobr:contains("Question 3")').closest('tr').hide();
$('nobr:contains("Question 4")').closest('tr').hide();
} else {
$('nobr:contains("Question 1")').closest('tr').show();
$('nobr:contains("Question 2")').closest('tr').show();
$('nobr:contains("Question 3")').closest('tr').show();
$('nobr:contains("Question 4")').closest('tr').show();
}
});
});
那么你的代码不会显示验证码,所以很难帮助你。 – epascarello
感谢您的回复epascarello。你能帮我解决吗? –
我不能因为我说的原因。你如何做验证。 – epascarello