sandhya Posted May 2, 2009 Share Posted May 2, 2009 Hi all, I"ve a form in php. In that form i "ve 2 submit buttons & 1 normal button. The problem is when ever i click any button, i have to proceed to a particular function. But i'm not able to proceed. I'm able to enter into the function. But able to proceed at form field validation. In error console, it displaying an error like document.form1.nrec is not defined.This error is for every form field. Is there any problem with the form. Please help me. Quote Link to comment Share on other sites More sharing options...
the182guy Posted May 2, 2009 Share Posted May 2, 2009 You'll need to show us the form. From that error I would guess that either your form does not have a name of "form1" or your fields aren't named the same as what the javascript is looking for. Quote Link to comment Share on other sites More sharing options...
sandhya Posted May 2, 2009 Author Share Posted May 2, 2009 Hi there, Actually the form is one of e-commerce form. n' it is a very lengthy form. can i post it here? Quote Link to comment Share on other sites More sharing options...
the182guy Posted May 2, 2009 Share Posted May 2, 2009 Yes post it here. Quote Link to comment Share on other sites More sharing options...
sandhya Posted May 2, 2009 Author Share Posted May 2, 2009 <? ob_start(); session_start(); header("Cache-control: private"); include_once("include/include.php"); ?><html> <head> <title>WWW.akrjewellers.com...Your Cart</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript"> function mnat() { window.open('delview.php','nbt','height=400,width=500,left=200,top=100,status=no,menubar=no,resizable=0,scrollbars=yes'); } function manasan1(srt) { var mn=true; var q1=eval(document.form1.nrec.value); for(u=0;u<q1;u++) { mft=u*3; var utr=document.form1.elements[mft].value; if(trimString(utr)=="") { alert("Enter Quantity"); mn=false; document.form1.elements[mft].value=""; document.form1.elements[mft].focus(); break; } else if(numcheck(utr)==false) { alert("Invalid quantity Entered"); mn=false; document.form1.elements[mft].focus(); break; } else { continue; } } if(mn==true) { for(u=0;u<q1;u++) { mft=(u*3)+1; var utr=document.form1.elements[mft].value; if(trimString(utr).length>100) { alert("Message should be less than 100 characters"); mn=false; document.form1.elements[mft].focus(); break; } else { continue; } } } if(mn==true) { if(trimString(document.form1.spmess.value).length>150) { alert("Special message should be less than 150 characters"); mn=false; document.form1.spmess.focus(); } } if(mn==true) { document.form1.direct.value="continue"; document.form1.redirect.value=srt; document.form1.submit(); } } function manasan2(srt) { var mn=true; var q1=eval(document.form1.nrec.value); for(u=0;u<q1;u++) { mft=u*3; var utr=document.form1.elements[mft].value; if(trimString(utr)=="") { alert("Enter Quantity"); mn=false; document.form1.elements[mft].value=""; document.form1.elements[mft].focus(); break; } else if(numcheck(utr)==false) { alert("Invalid quantity Entered"); mn=false; document.form1.elements[mft].focus(); break; } else { continue; } } if(mn==true) { for(u=0;u<q1;u++) { mft=(u*3)+1; var utr=document.form1.elements[mft].value; if(trimString(utr).length>100) { alert("Message should be less than 100 characters"); mn=false; document.form1.elements[mft].focus(); break; } else { continue; } } } if(mn==true) { if(trimString(document.form1.spmess.value).length>150) { alert("Special message should be less than 150 characters"); mn=false; document.form1.spmess.focus(); } } if(mn==true) { document.form1.direct.value="checkout"; document.form1.redirect.value=srt; document.form1.submit(); } } function chk(form1) { var mn=true; var q1=eval(form1.nrec.value); for(u=0;u<q1;u++) { mft=u*3; var utr=form1.elements[mft].value; if(trimString(utr)=="") { alert("Enter Quantity"); mn=false; form1.elements[mft].value=""; form1.elements[mft].focus(); break; } else if(numcheck(utr)==false) { alert("Invalid quantity Entered"); mn=false; form1.elements[mft].focus(); break; } else { continue; } } if(mn==true) { for(u=0;u<q1;u++) { mft=(u*3)+1; var utr=form1.elements[mft].value; if(trimString(utr).length>100) { alert("Message should be less than 100 characters"); mn=false; form1.elements[mft].focus(); break; } else { continue; } } } if(mn==true) { if(trimString(document.form1.spmess.value).length>150) { alert("Special message should be less than 150 characters"); mn=false; document.form1.spmess.focus(); } } if(mn==true) { document.form1.direct.value="update"; return true; } else { return false; } } function numcheck(str) { var tr=true; var s=str.length; if(s==0) { return true; } else { for(i=0;i<s;i++) { if(str.charCodeAt(i)<48||str.charCodeAt(i)>57) { tr=false; break; } } if(tr==false) { return false; } else { return true; } } } function trimString (str) { while (str.charAt(0) == ' ') str = str.substring(1); while (str.charAt(str.length - 1) == ' ') str = str.substring(0, str.length - 1); return str; } </script> </head> <body> <? if(!empty($_GET['remove'])) { $sqlup=executeupdate("delete from temp_orderdetails where temp_id=" . $_GET['remove']); } if(!empty($_POST['direct'])) { $rty=(int) $_POST['nrec']; $mp=$_POST['nrec']-1; if($rty != 0) { for($j=0;$j<$rty;$j++) { $mnp='text'.$j; $mnp2='area'.$j; $mnp3='qid'.$j; $newmess=$_POST[$mnp2]; $mp1=$_POST[$mnp]; $ids=$_POST[$mnp3]; if ($mp1 != 0) { $sqlup=executework("select * from temp_orderdetails where order_id=" . $cid1 . " and temp_id=" .$ids); $countc=@mysql_num_rows($sqlup); if($countc >0) { $row1=@mysql_fetch_array($sqlup); $mes=""; $sqlup=executework("update temp_orderdetails set order_product_qty=".$mp1." , order_messageon='".$mes."' where order_id=" . $cid1 . " and temp_id=" . $ids); } } else { $sqlup=executeupdate("delete from temp_orderdetails where order_id=" . $cid1 . " and temp_id=" . $ids); } } } if($_POST['direct']=="checkout") { redirect("checkout.php"); } if($_POST['direct']=="continue") { redirect($_POST['redirect']); } session_register("spmess"); $spmess=$_POST['spmess']; } ?> <? if (session_is_registered("bakeuser")) { include_once("header2.php"); } else { include_once("header.php"); } $cid=""; $cqty=0; $cmess=""; $cweight=""; $cprice=""; $cflavour=""; $rpage=""; if($_POST['rpage']=="") { if (!empty($_GET['rpage'])) { $rpage=$_GET['rpage']; } } else { $rpage=$_POST['rpage']; } if(empty($_POST['id'])) { } else { $cid=(int)trim($_POST['pid']); $cqty=(int)trim($_POST['qty']); $sqla=executework("select product_priceinDS from product where product_id=" . $cid); $counta=@mysql_num_rows($sqla); if($counta>0) { $rowa=@mysql_fetch_array($sqla); $cpr=$rowa["product_priceinDS"]; } } if(empty($_GET['id'])) { } else { $cid=(int)trim($_GET['id']); $cqty=(int)trim($_GET['qty']); $sqla=executework("select product_priceinDS from product where product_id=" . $cid); $counta=@mysql_num_rows($sqla); if($counta>0) { $rowa=@mysql_fetch_array($sqla); $cpr=$rowa["product_priceinDS"]; } } if(!empty($_POST[id])) { $cid=$_POST['id']; $cqty=$_POST['qty']; $cpr=$_POST[total]; } if(!empty($_POST['messg'])) { $cmesst=trim($messg); } if(!empty($_POST['weight'])) { $cwt=trim($weight); } if(!empty($_POST['flavour'])) { $vflavour=trim($flavour); } if(!empty($_POST['price'])) { $cprice=trim($price); } if($cid != "") { if(!session_is_registered("cid")) { $sql = executework("select max(temp_id) from temp_orderdetails"); $row=@mysql_fetch_array($sql); if(is_null($row[0])) { $maxidte=1; } else { $maxidte=(int)$row[0]+1; } $sql = executework("select max(order_id) from temp_orderdetails"); $row=@mysql_fetch_array($sql); if(is_null($row[0])) { $maxid=1; } else { $maxid=(int)$row[0]+1; } session_register("cid1"); $cid1=$maxid; session_register("maxidt"); $maxidt=$maxidte; $sql2 = executeupdate("insert into temp_orderdetails(temp_id,order_id,order_product_id,order_product_weight,order_product_flavour,order_product_upriced,order_product_qty,order_messageon) values($maxidt,$cid1,$cid,'$cwt','$cflavour',$cpr,$cqty,'$cmess')"); } else { $sql = executework("select product_category from product where product_id=" . $cid); $row=@mysql_fetch_array($sql); if ($row["product_category"]=="free") { $sql = executework("select count(*) from temp_orderdetails where order_id=" . $cid1 . " and order_product_id in(select product_id from product where product_category='free')"); $count = @mysql_num_rows($sql); if($count > 0) { redirect("uncart.php"); } } $sql = executework("select * from temp_orderdetails where order_id=" . $cid1 . " and order_product_id=" . $cid . " and order_product_upriced=" . $cpr); $count = @mysql_num_rows($sql); if($count>0) { $row=@mysql_fetch_array($sql); $modqty=$row["order_product_qty"]+$cqty; $sql5 = executework("update temp_orderdetails set order_product_qty=".$modqty." where where order_id=" . $cid1 . " and order_product_id=" . $cid . " and order_product_upriced=" . $cpr); } else { $sql2 = executeupdate("insert into temp_orderdetails(temp_id,order_id,order_product_id,order_product_weight,order_product_flavour,order_product_upriced,order_product_qty,order_messageon) values($maxidt,$cid1,$cid,'$cwt','$cflavour',$cpr,$cqty,'$cmess')"); } } } ?> <form action="shoppingcart.php?rpage=<? echo $rpage ?>" method="post" name="form1" onSubmit="return chk(this)"> <div align="center"> <table width="98%" align="center" cellpadding="4" cellspacing="4" bgcolor="#FFFEFD"> <tr> <td colspan="7" align="center"> </td> </tr> <? if(!session_is_registered("cid1")) { ?> <tr> <td colspan="7" align="right"> </td> </tr> <tr> <td colspan="7" align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">No Items in Your Cart.</font></strong></td> </tr> <tr> <td colspan="7" align="center"> </td> </tr> <tr align="center"> <td colspan="7"><input type="button" name="Submit" value="Continue shopping" onClick="location.href='<? echo $rpage ?>'"></td> </tr> <? } else { $sql0 = executework("select * from temp_orderdetails where order_id=" . $cid1 . " order by temp_id"); $count2=@mysql_num_rows($sql0); $sno=1; $netamt=0; $cart=0; $row=@mysql_fetch_array($sql0); if($count2 >0) { ?> <tr bordercolor="#FF8929" bgcolor="#FFF8F2"> <td colspan="7" align="left" bgcolor="#EEF2F7"><font size="2" face="Arial, Helvetica, sans-serif"><strong>How to edit your cart?</strong></font><br> <li><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">To change quantity, edit quantity of the relevant product and press 'Update Cart' button.</font></li> <li><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">To remove a product from shopping cart change corresponding product quantity to zero and press 'Update Cart' button.</font></li> </td> </tr> <tr bgcolor="#FFCEA6"> <td width="9%" align="center" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">SL.No.</font></strong></td> <td width="18%" align="center" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">Model ID</font></strong></td> <td width="21%" align="center" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">Name</font></strong></td> <td width="20%" align="center" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">Unit Price ($)</font></strong></td> <td width="6%" align="center" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">Weight</font></strong></td> <td width="15%" align="center" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">Quantity</font></strong></td> <td width="17%" align="right" bgcolor="#B7C8D9"><strong><font size="2" face="Arial, Helvetica, sans-serif">Price ($)</font></strong></td> </tr> <? $netamt=0; for($k=0;$k<$count2;$k++) { $sqlt = executework("select product_modelid,product_name,product_category from product where product_id=" . $row[order_product_id]); $countt=@mysql_num_rows($sqlt); $rowt=@mysql_fetch_array($sqlt); $mid1=$rowt["product_modelid"]; $mname=$rowt["product_name"]; $mcat=$rowt["product_category"]; ?> <tr align="center" bordercolorlight="#0066FF" bgcolor="#FFEAD9"> <td colspan="7" bgcolor="#EEF2F7"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr align="center" bordercolor="#FFFFFF"> <td width="10%"><div align="left"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $k+1 ?></font></div></td> <td width="18%"><div align="left"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $mid1 ?></font></div></td> <? if (!empty($row["order_product_weight"])) { ?> <td width="21%"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $mname ?> </font></div></td> <? } else { ?> <td width="21%"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $mname ?> </font></div></td> <? } ?> <td width="12%"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $row["order_product_upriced"] ?></font></div></td> <td width="12%" align="right"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $cwt ?> (gms)</font></td> <? if ($mcat=="free") { ?> <td width="6%" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="shoppingcart.php?remove=<? echo $row[temp_id] ?>&rpage=<? echo $rpage ?>">Remove</a></font></td> <input name="text<? echo $k ?>" type="hidden" value="<? echo $row[order_product_qty] ?>" size="2" maxlength="2"> <? } else { ?> <td width="14%"> <div align="right"> <input name="text<? echo $k ?>" id="text<? echo $k ?>" type="text" value="<? echo $row[order_product_qty] ?>" size="2" maxlength="2" > </div></td><? } $totprice=($row["order_product_qty"]* $row["order_product_upriced"]); $netamt=$netamt+$totprice; ?> <td width="17%" align="right"><font size="2" face="Arial, Helvetica, sans-serif"><? echo $totprice ?></font></td> </tr> <? if ($mcat=="cake") { ?> <tr> <td colspan="7" align="center" valign="top" bordercolor="#FFFFFF"> </td> </tr> <? } else { ?> <br> <? } ?> </table></td> </tr> <input type="hidden" name="qid<? echo $k ?>" value="<? echo $row[temp_id] ?>"> <? $row=@mysql_fetch_array($sql0); } ?> <input type="hidden" name="nrec" value="<? echo $count2 ?>"> <tr bgcolor="#FFC99D"> <td colspan="6" align="right" bgcolor="#B7C8D9"><div align="right"><strong><font size="2" face="Arial, Helvetica, sans-serif">Total Price : </font></strong></div></td> <td align="right" bgcolor="#B7C8D9"><div align="right"><strong><font size="2" face="Arial, Helvetica, sans-serif"> <? echo $netamt ?></font></strong></div></td> </tr> <tr bgcolor="#FFF3EA"> <td colspan="7" align="left" bgcolor="#EEF2F7"> <table width="99%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="69%"><strong><font size="2" face="Arial, Helvetica, sans-serif">you can enter special instruction and message with this order here</font></strong> </td> <td width="31%"> <div align="right"> <textarea rows=2 cols="20" name="spmess"><? echo $spmess ?></textarea> </div></td> </tr> </table></td> </tr> <? if ($netamt==0.00) { } else { ?> <tr bgcolor="#FFF3EA"> <td colspan="7" align="left" bgcolor="#EEF2F7"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Shipping charge will be added to the total amount according to the delivery area you will choose upon checkout. To view shipping charges </font><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="javascript:mnat()"><strong>click here</strong></a></font></td> </tr> <? } ?> <tr bgcolor="#FFE4CE"> <td colspan="7" align="left" bgcolor="#EEF2F7"> </td> </tr> <tr align="center" bgcolor="#FFC99D"> <td colspan="7" bgcolor="#B7C8D9"><input type="button" name="Button" value="Continue Shopping" onClick="manasan1('<? echo $rpage ?>')"> <input type="submit" name="Submit2" value="Update Cart" > <input type="button" name="Submit3" value="Checkout" onClick="manasan2('checkout.php')"></td> <input type="hidden" name="direct" value=""> <input type="hidden" name="redirect" value=""> </tr> <? } else { ?> <tr> <td colspan="7" align="right"> </td> </tr> <tr> <td colspan="7" align="right"> </td> </tr> <tr> <td colspan="7" align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">No Items in Your Carts.</font></strong></td> </tr> <tr> <td colspan="7" align="center"> </td> </tr> <tr align="center"> <td colspan="7"><input type="button" name="Submit" value="Continue shopping" onClick="location.href='<? echo $rpage ?>'"></td> </tr> <? } } ?> </table> </div> </form> <!--</td> </tr> </table> --> <map name="map"> <area shape="circle" coords="167,13,11" href="index.php"> <area shape="circle" coords="123,30,15" href="security.php"> <area shape="circle" coords="74,46,14" href="shoppingcart.php?rpage=<? echo $rpage ?>"> <area shape="circle" coords="20,59,17" href="members.php"> <area shape="circle" coords="154,34,3" href="#"> <area shape="rect" coords="54,67,107,81" href="shoppingcart.php?rpage=<? echo $rpage?>"> <area shape="rect" coords="2,84,118,99" href="members.php"> <area shape="rect" coords="111,50,154,65" href="security.php"> <area shape="rect" coords="151,32,190,44" href="index.php"> </map> <map name="Map2"> <area shape="rect" coords="1,2,104,20" href="shipping.php"> <area shape="rect" coords="103,1,175,21" href="aboutus.php"> <area shape="rect" coords="175,2,226,19" href="shoppingcart.php?rpage=<? echo $rpage ?>"> </map> <map name="Map3"> <area shape="rect" coords="1,3,22,19" href="shoppingcart.php?rpage=<? echo $rpage?>"> <area shape="rect" coords="24,2,123,20" href="track.php"> <area shape="rect" coords="128,2,207,17" href="contactus.php"> </map> <map name="Map4"> <area shape="rect" coords="4,11,166,89" href="index.php"> </map> <map name="Map5"> <area shape="rect" coords="1,11,62,89" href="index.php"> </map> <? // -----------------------------include footer-------------------------------------- include_once("footer1.php"); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
sandhya Posted May 2, 2009 Author Share Posted May 2, 2009 Hi is there any problem? Quote Link to comment Share on other sites More sharing options...
sandhya Posted May 2, 2009 Author Share Posted May 2, 2009 Are you there? Quote Link to comment Share on other sites More sharing options...
the182guy Posted May 2, 2009 Share Posted May 2, 2009 Is this page live on the Internet somewhere? It would be easier to debug if I can see it in the web browser. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.