表单有问题?
嗨,你好啊,
我以前真的没有做过太多,但我一直试图转换一种表格,供当地慈善机构使用,但似乎不起作用:
Http://www.p-s-i.org.uk/temp/email.html
如果有人能帮忙,我将不胜感激.
多谢,
D
# 回答1
您正在使用的函数如下:
您正在使用的函数如下:
选择 | 换行 | 行号
- function PostCodeInSwindon() {
- // code here something to extract the first (non-blank) four characters of the postcode
- postcode=document.getinput.postcode.value;
- postcode=postcode.toUpperCase()+' ';
- postcode=postcode.substring(0,4);
- InSwindon=false;
- // check for those postcodes in Swindon
- switch(postcode) {
- case "SN1":
- InSwindon=true;
- break;
- case "SN2":
- InSwindon=true;
- break;
- case "SN3":
- InSwindon=true;
- break;
- case "SN4":
- InSwindon=true;
- break;
- case "SN5":
- InSwindon=true;
- break;
- case "SN25":
- InSwindon=true;
- break;
- case "SN26":
- InSwindon=true;
- break;
- }
- // display the processed postcode
- getinput.processed.value=postcode;
- // display a different result in an input box depending on whether the postcode is in Swindon or not
- if (InSwindon) {getinput.result.value="Swindon"}
- else {getinput.result.value="Not Swindon"}
- // call a different file depending on whether the postcode was in Swindon or not
- if (InSwindon) {destinationpage = "swindonemail.html" + "?Swindon"; top.location.href = destinationpage }
- else {top.location = "noemail.htm"}
- return
- }
它在这里被称为:
选择 | 换行 | 行号
- <FORM NAME="getinput" onSubmit="PostCodeInSwindon(); return false;" enctype="text/plain">
一个问题是,它应该是:
选择 | 换行 | 行号
- onsubmit = "return PostCodeInSwindon();"
另一个原因是,getinput不是全局的:您需要使用Document.getinput来引用表单.
还有一个问题是,您的邮政编码有4个字符,但您只检查了3个字符(对于Switch语句中的大多数情况).
标签: Javascript