这与我之前提出的问题有关:Hide / Show Multiple Divs
我已经从我之前的问题中获得了代码,除了当我在“之后”选择票证时更改下拉列表中的值时,它似乎工作正常。
我有很多 Javascrpts,所以想知道某处是否存在冲突?代码的第一位在文档的 HEAD 中。
<head>
<script type="text/javascript">
$(function() {
$('.cat_dropdown').change(function() {
$('#payMethod').toggle($(this).val() >= 2);
});
});
</script>
<script type="text/javascript">
$(document).ready(function () {
$(".paymentmethod").click(function () {
$(".paymentinfo").hide();
switch ($(this).val()) {
case "Credit Card Authorisation":
$("#pay0").show("slow");
break;
case "Direct Deposit":
$("#pay1").show("slow");
break;
case "Cash Payment (FAA Office)":
$("#pay2").show("slow");
break;
}
});
});
</script>
</head>
第二段代码是表单验证:
<script src="/CatalystScripts/ValidationFunctions.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var submitcount27389 = 0;function checkWholeForm27389(theForm){
var why = "";
if (theForm.FirstName) why += isEmpty(theForm.FirstName.value, "First Name");
if (theForm.LastName) why += isEmpty(theForm.LastName.value, "Last Name");
if (theForm.HomeAddress) why += isEmpty(theForm.HomeAddress.value, "Home Address");
if (theForm.HomeCity) why += isEmpty(theForm.HomeCity.value, "Home City");
if (theForm.HomeState) why += isEmpty(theForm.HomeState.value, "Home State");
if (theForm.HomeZip) why += isEmpty(theForm.HomeZip.value, "Home Zipcode");
if (theForm.HomeCountry) why += checkDropdown(theForm.HomeCountry.value, "Home Country");
if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);
if (theForm.HomePhone) why += isEmpty(theForm.HomePhone.value, "Home Phone Number");
if (theForm.CAT_Custom_266106) why += checkDropdown(theForm.CAT_Custom_266106.value, "Available Dates:");
if (theForm.CAT_Custom_266143) why += checkDropdown(theForm.CAT_Custom_266143.value, "Member Tickets:");
if (theForm.CAT_Custom_266107) why += checkDropdown(theForm.CAT_Custom_266107.value, "Guest Tickets:");
if (theForm.CAT_Custom_266105 && theForm.CAT_Custom_266107.value != "1")
why += checkSelected(theForm.CAT_Custom_266105, "Payment Options:");
if (theForm.CAT_Custom_266104) why += checkDropdown(theForm.CAT_Custom_266104.value, "Where did you hear about us?");
if (theForm.CaptchaV2) why += captchaIsInvalid(theForm, "Enter Word Verification in box below", "Please enter the correct Word Verification as seen in the image"); if(why != ""){
alert(why);
return false;
}
if(submitcount27389 == 0){
submitcount27389++;
theForm.submit();
return false;
}else{
alert("Form submission is in progress.");
return false;
}
}
//]]>
</script>
</form>
如果您想测试它并查看结果,可以在http://www.faa.net.au/test/femmes-event-rego-form.html找到该页面。
您需要选择 1 位以上的 GUEST,然后选择 CREDIT CARD AUTHORIZATION,最后在“您从哪里听说我们?”中选择一些内容。下拉菜单看看会发生什么。
我不明白为什么一旦我在最后一个下拉菜单中更改了一个值,DIV 就会隐藏?
我添加了一个 JSFiddle - http://jsfiddle.net/4REan/ - 但我无法让它正常工作,但希望那里的所有代码都会有所帮助?