trouble with form info after "add to cart" button is clicked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
So i have a paypal form set up on my site http;//ducwc.ca/3VG.html its for our club's annual rally with options for hotel, BBQ tickets and t-shirts.
Now when the form is submitted, instead of showing only the items that were checked off it shows checked items plus the default names of items that were not checked off, which makes it hard on my end to properly calculate the actual purchase.
here is an example: Event / Nickname / Real name / Hotel / BBQ / t-shirts (notice that the t-shirts not picked also showed up) and then the info is cut off, i assume paypal only allows so many characters
3VG2012:, tufduc, Chris Speers, 3xD1b @420, 1BBQ +30, Short S +25, Medium, Short L +25, X-Large, XX-Large, XXX-Large, Small, Me
Here is a copy of the coding i have as well
Your help is greatly appreciated
</script> <script type="text/javascript"> // function Dollar (val) { // force to valid dollar amount var str,pos,rnd=0; if (val < .995) rnd = 1; // for old Netscape browsers str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape pos = str.indexOf ("."); if (pos > 0) str = str.substring (rnd, pos + 3); return str; } var amt,des,obj,val,op1a,op1b,op2a,op2b,itmn; function ChkTok (obj1) { var j,tok,ary=new Array (); // where we parse ary = val.split (" "); // break apart for (j=0; j<ary.length; j++) { // look at all items // first we do single character tokens... if (ary[j].length < 2) continue; tok = ary[j].substring (0,1); // first character val = ary[j].substring (1); // get data if (tok == "@") amt = val * 1.0; if (tok == "+") amt = amt + val*1.0; if (tok == "%") amt = amt + (amt * val/100.0); if (tok == "-") amt = amt - val*1.0; if (tok == "#") { // record item number if (obj1.item_number) obj1.item_number.value = val; ary[j] = ""; // zap this array element } // Now we do 3-character tokens... if (ary[j].length < 4) continue; tok = ary[j].substring (0,3); // first 3 chars val = ary[j].substring (3); // get data if (tok == "s1=") { // value for shipping if (obj1.shipping) obj1.shipping.value = val; ary[j] = ""; // clear it out } if (tok == "s2=") { // value for shipping2 if (obj1.shipping2) obj1.shipping2.value = val; ary[j] = ""; // clear it out } } val = ary.join (" "); // rebuild val with what's left } function StorVal () { var tag; tag = obj.name.substring (obj.name.length-2); // get flag if (tag == "1a") op1a = op1a + " " + val; else if (tag == "1b") op1b = op1b + " " + val; else if (tag == "2a") op2a = op2a + " " + val; else if (tag == "2b") op2b = op2b + " " + val; else if (tag == "3i") itmn = itmn + " " + val; else if (des.length == 0) des = val; else des = des + ", " + val; } function ReadForm (obj1, tst) { // Read the user form var i,j,pos; amt=0;des="";op1a="";op1b="";op2a="";op2b="";itmn=""; if (obj1.baseamt) amt = obj1.baseamt.value*1.0; // base amount if (obj1.basedes) des = obj1.basedes.value; // base description if (obj1.baseon0) op1a = obj1.baseon0.value; // base options if (obj1.baseos0) op1b = obj1.baseos0.value; if (obj1.baseon1) op2a = obj1.baseon1.value; if (obj1.baseos1) op2b = obj1.baseos1.value; if (obj1.baseitn) itmn = obj1.baseitn.value; for (i=0; i<obj1.length; i++) { // run entire form obj = obj1.elements[i]; // a form element if (obj.type == "select-one") { // just selects if (obj.name == "quantity" || obj.name == "amount") continue; pos = obj.selectedIndex; // which option selected val = obj.options[pos].value; // selected value ChkTok (obj1); // check for any specials if (obj.name == "on0" || // let this go where it wants obj.name == "os0" || obj.name == "on1" || obj.name == "os1") continue; StorVal (); } else if (obj.type == "checkbox" || // just get checkboxex obj.type == "radio") { // and radios if (obj.checked) { val = obj.value; // the value of the selection ChkTok (obj1); StorVal (); } } else if (obj.type == "select-multiple") { //one or more for (j=0; j<obj.options.length; j++) { // run all options if (obj.options[j].selected) { val = obj.options[j].value; // selected value (default) ChkTok (obj1); StorVal (); } } } else if ((obj.type == "text" || // just read text, obj.type == "textarea") && obj.name != "tot" && // but not from here obj.name != "quantity") { val = obj.value; // get the data if (val == "" && tst) { // force an entry alert ("Enter data for " + obj.name); return false; } StorVal (); } } // Now summarize stuff we just processed, above if (op1a.length > 0) obj1.on0.value = op1a; if (op1b.length > 0) obj1.os0.value = op1b; if (op2a.length > 0) obj1.on1.value = op2a; if (op2b.length > 0) obj1.os1.value = op2b; if (itmn.length > 0) obj1.item_number.value = itmn; obj1.item_name.value = des; obj1.amount.value = Dollar (amt); if (obj1.tot) obj1.tot.value = "$" + Dollar (amt); } //--> </script> <!-- Start of Form --> <!-- Note: target="paypal" was replaced with the variable target="_self" --> <!-- Note: shopping_url also added to code --> <!-- These two changes allow better functionality with IE and Firefox --> <!-- --> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = '_self'; return ReadForm(this, true);"> <!--<input type="hidden" name="cmd" value="_cart">--> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="business" value="account.at.paypal" /> <input type="hidden" name="page_style" value="DUCwc" /> <input type="hidden" name="item_name" value="3VG" /> <input type="hidden" name="item_number" /> <input type="hidden" name="item_name_1" value="Hotel" /> <input type="hidden" name="item_name_2" value="BBQ" /> <input type="hidden" name="item_name_3" value="S short" /> <input type="hidden" name="item_name_4" value="First Item" /> <input type="hidden" name="amount" /> <input type="hidden" name="currency_code" value="CAD" /> <input type="hidden" name="lc" value="US" /> <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_SM.gif:NonHosted" /> <!-- --> <input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/your_page.html" /> <input type="hidden" name="cancel_return" value="http://www.yourwebsite.com/Cancel.html" /> <input type="hidden" name="return" value="http://www.yourwebsite.com" /> <!-- --> <input type="hidden" name="baseamt" value="00" /> <input type="hidden" name="basedes" value="3VG2012:" /> <!-- --> <input type="hidden" name="baseon0" /> <input type="hidden" name="baseos0" /> <input type="hidden" name="baseon1" /> <input type="hidden" name="baseos1" /> <input type="hidden" name="baseitn" /> <!-- --> <input type="hidden" name="on0" /> <input type="hidden" name="os0" /> <input type="hidden" name="on1" /> <input type="hidden" name="os1" /> <!-- --> <table width="100%" id="form"> <tr><th bgcolor="#FF0000">DUCwc 3 Valley Gap Registration Form</th></tr> <tr><td><br /> <input type="hidden" name="User Name" value="Your DUCwc Username" />Your DUCwc Username<br /> <input type="text" name="User Name" maxlength="60" /> <br /><br /> <input type="hidden" name="Real Name" value="Your Real Name" />Your Real Name<br /> <input type="text" name="Real Name" maxlength="60" /> <br /><br /> <!-- --> Hotel Accomodation: <br /> <select value="Accomodation" name="item_name_1" onchange="ReadForm (this.form, false);"> <option>Please Choose</option> <option value="3xS @375">3 Nights Single, 1 Adult, 1 Bed - $375.00</option> <option value="3xD1b @420">3 Nights Double, 2 Adults, 1 Bed - $420.00</option> <option value="3xD2b @420">3 Nights Double, 2 Adults, 2 Beds - $420.00</option> <option value="3xT @480">3 Nights Triple, 3 Adults, 3 Beds - $480.00</option> <option value="3xD1c @435">3 Nights Double w/ 1 child, 2 Beds - $435.00</option> <option value="3xD2c @480">3 Nights Double w/ 2 child, 3 Beds - $480.00</option> <option value="2xS @250">2 Nights Single, 1 Adult, 1 Bed - $250.00</option> <option value="2xD1b @280">2 Nights Double, 2 Adults, 1 Bed - $280.00</option> <option value="2xD2b @280">2 Nights Double, 2 Adults, 2 Beds - $280.00</option> <option value="2xT @320">2 Nights Triple, 3 Adults, 3 Beds - $320.00</option> <option value="2xD1c @290">2 Nights Double w/ 1 child, 2 Beds - $290.00</option> <option value="2xD2c @320">2 Nights Double w/ 2 child, 3 Beds - $320.00</option> </select> <!-- --> </td></tr> <tr><td> <br /> <!-- --> BBQ and Ghost Town Tour $30.00: <br /> <select value="BBQ" name="item_name_2" onchange="ReadForm (this.form, false);"> <option>Please Choose</option> <option value="1BBQ +30">1 Attending - $30.00</option> <option value="2BBQ +60">2 Attending - $60.00</option> <option value="3BBQ +90">3 Attending - $90.00</option> <option value="4BBQ +120">4 Attending - $120.00</option> </select> <!-- --> </td></tr> <tr><td> <br /> <!-- --> 3VG T-Shirt Short Sleeve $25.00: <br /> <select name="Small" name="item_name_3" onchange="ReadForm (this.form, false);"> <option>Small</option> <option value="Short S +25">1 Small</option> <option value="Short S +50">2 Small</option> <option value="Short S +75">3 Small</option> <option value="Short S +100">4 Small</option> <option value="Short S +125">5 Small</option> </select> <!-- --> <select name="Medium" onchange="ReadForm (this.form, false);"> <option>Medium</option> <option value="Short M +25">1 Medium</option> <option value="Short M +50">2 Medium</option> <option value="Short M +75">3 Medium</option> <option value="Short M +100">4 Medium</option> <option value="Short M +125">5 Medium</option> </select> <!-- --> <select name="Large" onchange="ReadForm (this.form, false);"> <option>Large</option> <option value="Short L +25">1 Large</option> <option value="Short L +50">2 Large</option> <option value="Short L +75">3 Large</option> <option value="Short L +100">4 Large</option> <option value="Short L +125">5 Large</option> </select> <!-- --> <select name="X-Large" onchange="ReadForm (this.form, false);"> <option>X-Large</option> <option value="Short XL +25">1 X-Large</option> <option value="Short XL +50">2 X-Large</option> <option value="Short XL +75">3 X-Large</option> <option value="Short XL +100">4 X-Large</option> <option value="Short XL +125">5 X-Large</option> </select> <!-- --> <select name="XX-Large" onchange="ReadForm (this.form, false);"> <option>XX-Large</option> <option value="Short XXL +25">1 XX-Large</option> <option value="Short XXL +50">2 XX-Large</option> <option value="Short XXL +75">3 XX-Large</option> <option value="Short XXL +100">4 XX-Large</option> <option value="Short XXL +125">5 XX-Large</option> </select> <!-- --> <select name="XXX-Large" onchange="ReadForm (this.form, false);"> <option>XXX-Large</option> <option value="Short XXXL +25">1 XXX-Large</option> <option value="Short XXXL +50">2 XXX-Large</option> <option value="Short XXXL +75">3 XXX-Large</option> <option value="Short XXXL +100">4 XXX-Large</option> <option value="Short XXXL +125">5 XXX-Large</option> </select> <!-- --> </td></tr> <tr><td> <br /> <!-- --> 3VG T-Shirt Long Sleeve $30.00: <br /> <select name="Small" onchange="ReadForm (this.form, false);"> <option>Small</option> <option value="Long S +30">1 Small</option> <option value="Long S +60">2 Small</option> <option value="Long S +90">3 Small</option> <option value="Long S +120">4 Small</option> <option value="Long S +150">5 Small</option> </select> <!-- --> <select name="Medium" onchange="ReadForm (this.form, false);"> <option>Medium</option> <option value="Long M +30">1 Medium</option> <option value="Long M +60">2 Medium</option> <option value="Long M +90">3 Medium</option> <option value="Long M +120">4 Medium</option> <option value="Long M +150">5 Medium</option> </select> <!-- --> <select name="Large" onchange="ReadForm (this.form, false);"> <option>Large</option> <option value="Long L +30">1 Large</option> <option value="Long L +60">2 Large</option> <option value="Long L +90">3 Large</option> <option value="Long L +120">4 Large</option> <option value="Long L +150">5 Large</option> </select> <!-- --> <select name="X-Large" onchange="ReadForm (this.form, false);"> <option>X-Large</option> <option value="Long XL +30">1 X-Large</option> <option value="Long XL +60">2 X-Large</option> <option value="Long XL +90">3 X-Large</option> <option value="Long XL +120">4 X-Large</option> <option value="Long XL +150">5 X-Large</option> </select> <!-- --> <select name="XX-Large" onchange="ReadForm (this.form, false);"> <option>XX-Large</option> <option value="Long XXL +30">1 XX-Large</option> <option value="Long XXL +60">2 XX-Large</option> <option value="Long XXL +90">3 XX-Large</option> <option value="Long XXL +120">4 XX-Large</option> <option value="Long XXL +150">5 XX-Large</option> </select> <!-- --> <select name="XXX-Large" onchange="ReadForm (this.form, false);"> <option>XXX-Large</option> <option value="Long XXXL +30">1 XXX-Large</option> <option value="Long XXXL +60">2 XXX-Large</option> <option value="Long XXXL +90">3 XXX-Large</option> <option value="Long XXXL +120">4 XXX-Large</option> <option value="Long XXXL +150">5 XXX-Large</option> </select> <!-- --> </td></tr> <tr><td> <br /><br /><br /> <!-- --> Total Cost > <input class="nbor" type="text" name="tot" size="8" value="$0.00" /> <!-- --> <input type = "button" value = "Reset FORM" onclick = "this.form.reset();" /> <!-- --> </td></tr> <tr><td> <br /> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_SM.gif" name="submit" alt="cart add" /><br /><br /> * You can purchase via credit card even if you do not have a Palpal account.<br /> * Discounted room rates include 12% HST. <!--<input type="hidden" name="hosted_button_id" value="5PDBZKXASYA7L">--> </td></tr> </table> </form>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DUCwc -
Welcome to the Community!
That's quite a bit of coding - good job! I would recommend checking out X.com, our online developer community. There, you'll find thousands of developers who integrate PayPal as part of their websites, applications, and forms. You'll also find documentation on all the various PayPal services, from Website Payments Standard right up to our most advanced offerings.
Thanks!
Adrian
Did my post solve the issue? If so, please accept it as a solution!

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- I'm tryin to buy a subscription but..... in Buying with PayPal
- I wonder if your decision of settling “the claim in my favor” is really in my favor after all! in Buying with PayPal
- Instant Transfer suddenly blocked? in Buying with PayPal
- I have big NSF FEES and it's paypals fault in Buying with PayPal