var ro; var browser = navigator.appName; if(browser ==" Microsoft Internet Explorer"){ ro = new ActiveXObject(" Microsoft.XMLHTTP"); } else { ro = new XMLHttpRequest(); } 返回ro; } 函数CarpetJob(argW,argL,argType,argPad,argReq){ var宽度; var长度; var carpet; var padding; var install; width = document.carpetform.width.value; length = document.carpetform.length.value; carpet = document.carpetform.carpet.value; padding = document.carpetform.padding.value; install = document.carpetform.install 。值; http.open(''get''," carpet.php?width =" + argW +"& length =" + argL +"& carpet =" + argType +"& padding =" + argPad +"& install =" + argReq); http.onreadystatechange = handleResponse; http.send(null); } 函数handleResponse(){ if(http .readyState == 4){ document.getElementById(" results")。innerHTML = http.responseText; } } < / script> < body> < div id =" banner"> ; < h1> Zellers Carpeting< / h1> < h2>成本估算< / h3> < / div> < div class ="说明">输入所有相关参数,然后点击提交以估算您的房间铺设费用< / div> < div id =" userinput"> < form method =" get"名称= QUOT; carpetform" action ="#"> < table> < tr> < td>房间尺寸(以英尺为单位) ):< / td> < td>< input type =" text"名称= QUOT;宽度"> x< input type =" text" name =" length">< / td> < / tr> < tr> < td> ;< strong>地毯类型:< / strong>< / td> < td> < select name =" carpet"> < option value ="">选择地毯类型< /选项> < option value =" B"> Budget< / option> < option value =" S"> Standard< / option> < option value =" P"> Premium< / option> < / select> < / td> < / tr> < tr> < td>< strong>填充类型:< / strong>< / td> < td> < select name =" padding"> < option value ="" >选择填充< /选项> < option value =" S">标准< /选项> < option value =" P"> Premium< / option> < / select> < ; / td> < / tr> < tr> < td>< strong>需要安装:< / strong>< / td> < td>是< input type = radio name =" install" value = y>& nbsp;& nbsp;& nbsp; No < input type = radio name =" install" value = n>< / td> < / tr> < tr> < td align = center colspan = 2>< input type =" button"值= [提交" onclick =" CarpetJob();">< / td> < / tr> < / table> < / form> < / div> < div id =" results"> < / div> < / body> < / HTML> PHP PAGE <!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Transitional // EN" " http://www.w3。 org / TR / xhtml1 / DTD / xhtml1-Transitional.dtd"> < html xmlns =" http://www.w3.org/1999/xhtml"郎= QUOT;恩" xml:lang =" en"> < head> < meta http-equiv =" content-type" ;含量=" text / html的;字符集= ISO-8859-1" /> < title> Carpet< / title> < link type =" text / css"的rel ="样式表" HREF =" carpet.css" /> < / head> < body> < h1>地毯订单摘要:< / h1> < div id =" all"> <?php $ W = $ _ GET [''width'']; $ L = $ _ GET [''length'']; $ carpet = $ _ GET [''地毯'']; $ padding = $ _ GET [''padding'']; $ install = $ _ GET [''install'']; // 20%以上的公式 $ area = $ W * $ L; $ extra = $ area * .20 + $ area; ?> < br /> < br /> <?php //地毯价格 if($ carpet ==" B"){ $ c =" 1.00" ;; } if($ carpet ==" S"){ $ c =" 1.50"; } if($ carpet ==" P"){ $ c =" 2.00"; } $ carpetCost = $ c * $ extra; print("你的$ area ft.of Carpet将花费$ carpetCost"); ?> < br /> < br /> <?php //填充成本 if($ padding ==" S"){ $ cp = .35; } if($ padding ==" P"){ $ cp = .50; } $ cPadding = $ cp * $ extra; print("你的Padding将花费$$ cPadding") ?> < br /> < br /> <?php //安装费用 if($ install ==" n"){ $ in = .00; } if($ install ==" y"){ $ in = 2.00; } $ installCost = $ in * $ extra; print("您的安装费用将是$$ installCost"); ?> < br /> < br /> <?php $ salesTax =($ carpetCost + $ cPadding)*。07; 打印(您的销售税将为$$ salesTax); ?> < br /> < br /> <?php $ totalCost = $ carpetCost + $ cPadding + $ installCost + $ sal esTax; print(你的地毯总价为$$ totalCost); ?> < br /> < br /> <?php if($ carpet ==" B"){ print(''< img SRC =" budget.jpg" alt =" Budget Carpet" />''); } if($ carpet ==" S"){ print(''< img src =" standard.jpg" alt =" Standard Carpet" />''); } if($ carpet ==" P"){ print(''< img src =" premium。 jpg" alt =" Premium Carpet" />''); } ?> <?php if($ install ==" y"){ print('' < img src =" logo.jpg" alt =" logo" />''); } if($ install = =" n"){ } ?> < / div> < / body> < / html> [/ HTML] 解决方案 W = _GET [''width'']; L = anyone have any idea why i am not getting any return values? it will return the words just not the numbers?HTML[HTML]<HTML><head><title>Zellers Carpeting Cost Estimate</title></head><script>var http = createRequestObject();function createRequestObject() {var ro;var browser = navigator.appName;if(browser == "Microsoft Internet Explorer"){ro = new ActiveXObject("Microsoft.XMLHTTP");}else{ro = new XMLHttpRequest();}return ro;}function CarpetJob(argW,argL, argType, argPad, argReq) {var width;var length;var carpet;var padding;var install;width=document.carpetform.width.value;length=document.carpetform.length.value;carpet=document.carpetform.carpet.value;padding=document.carpetform.padding.value;install=document.carpetform.install.value;http.open(''get'', "carpet.php?width=" + argW +"&length="+ argL +"&carpet=" + argType +"&padding="+ argPad +"&install="+ argReq);http.onreadystatechange = handleResponse;http.send(null);}function handleResponse() {if(http.readyState == 4){document.getElementById("results").innerHTML = http.responseText;}}</script><body><div id="banner"><h1>Zellers Carpeting</h1><h2>Cost Estimate</h3></div><div class="instructions">Enter all the relevant parameters and click submit for an estimate of the cost of carpeting your room</div><div id="userinput"><form method="get" name="carpetform" action="#"><table> <tr> <td>Room Dimensions (in ft):</td><td><input type="text" name="width"> x <input type="text" name="length"></td> </tr> <tr><td ><strong>Type of Carpet:</strong></td><td> <select name="carpet"><option value="">Choose Carpet Type</option><option value="B">Budget</option><option value="S">Standard</option><option value="P">Premium</option> </select></td></tr><tr><td ><strong>Type of Padding:</strong></td><td><select name="padding"><option value="">Choose Padding</option><option value="S">Standard</option><option value="P">Premium</option></select></td></tr><tr><td><strong>Installation Required:</strong></td><td>Yes<input type=radio name="install" value=y>&nbsp;&nbsp;&nbsp;No<input type=radio name="install" value=n></td></tr><tr><td align=center colspan=2><input type="button" value="Submit" onclick="CarpetJob();"></td></tr></table></form></div><div id="results"></div></body></HTML>PHP PAGE<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Carpet</title> <link type="text/css" rel="stylesheet" href="carpet.css" /> </head><body><h1>The Summary of Your Carpet Order:</h1><div id="all"><?php$W=$_GET[''width''];$L=$_GET[''length''];$carpet=$_GET[''carpet''];$padding=$_GET[''padding''];$install=$_GET[''install''];//The formula for 20% more$area= $W * $L;$extra=$area * .20 + $area;?><br /><br /><?php//The carpet priceif($carpet=="B"){$c="1.00";}if($carpet=="S"){$c="1.50";}if($carpet=="P"){$c="2.00";}$carpetCost= $c * $extra;print ("Your $area ft. of Carpet will cost $$carpetCost");?><br /><br /><?php//Padding Costif($padding=="S"){$cp=.35;}if($padding=="P"){$cp=.50;}$cPadding=$cp * $extra;print ("Your Padding will cost $$cPadding")?><br /><br /><?php//The Install costif($install=="n"){$in=.00;}if($install=="y"){$in=2.00;}$installCost=$in * $extra;print ("Your install cost will be $$installCost");?><br /><br /><?php $salesTax=($carpetCost+$cPadding)*.07;print ("Your Sales Tax will be $$salesTax");?><br /><br /><?php $totalCost=$carpetCost+$cPadding+$installCost+$sal esTax;print ("Your Grand Total for your carpet is $$totalCost");?><br /><br /><?php if ($carpet=="B"){ print ('' <img src="budget.jpg" alt="Budget Carpet"/>'' ); } if ($carpet=="S"){ print (''<img src="standard.jpg" alt="Standard Carpet"/>''); } if ($carpet=="P"){ print (''<img src="premium.jpg" alt="Premium Carpet"/>''); }?><?php if ($install=="y"){ print (''<img src="logo.jpg" alt="logo"/>''); } if ($install=="n"){ }?></div></body></html>[/HTML] 解决方案 W=_GET[''width'']; L= 这篇关于没有从Ajax脚本获得正确的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-08 11:10