Multiple rows to database, not adding - javascript

I found this script to add rows to my form somewhere and I can add rows that works, the only problem is that when I submit it, only the first row are submitted. Never tried anything like this before so I might be completely off and if that is the case at least I will know that.
THIS IS THE HTML
<form name="addshow" action="addshow.php" method="post">
<input type="submit" value="Lägg till">
<input type="reset" value="Nollställ"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#add").click(function() {
$('#tableclassen tbody>tr:last').clone(true).insertAfter('#tableclassen tbody>tr:last');
return false;
});
});
</script>
<a id="add">+</a>
<TABLE id='tableclassen' cellpadding="3" cellspacing="0">
<TBODY>
<TR valign="top">
<TD width>
<input type="text" placeholder="ID" name="Horse_id" required oninvalid="this.setCustomValidity('Ange ID')" oninput="setCustomValidity('')" size="5"/>
</TD>
<TD>
<input type="text" placeholder="Årtal" name="years" required oninvalid="this.setCustomValidity('Ange årtal')" oninput="setCustomValidity('')" size="6"/>
</TD>
<TD>
<input type="text" placeholder="Plac." name="place" required oninvalid="this.setCustomValidity('Ange placering')" oninput="setCustomValidity('')" size="4"/>
</TD>
<TD>
<input type="text" placeholder="Ange eventnamn" name="event" required oninvalid="this.setCustomValidity('Ange eventnamn')" oninput="setCustomValidity('')" size="35"/>
</TD>
<TD>
<input type="text" placeholder="Ange klass" name="class" required oninvalid="this.setCustomValidity('Ange klass')" oninput="setCustomValidity('')" />
</TD>
<TD>
<input type="text" placeholder="Assoc." name="association" required oninvalid="this.setCustomValidity('Ange Assoc.')" oninput="setCustomValidity('')" size="6"/>
</TD>
<TD>
<input type="text" placeholder="Poäng" name="points" required oninvalid="this.setCustomValidity('Ange poänh')" oninput="setCustomValidity('')" size="3"/>
</TD>
<TD>
<select name="type" required oninvalid="this.setCustomValidity('Välj typ')" oninput="setCustomValidity('')">
<option value="" disabled selected>Välj typ</option>
<option value="SWE">SWE</option>
<option value="INTER">INTER</option>
</select>
</TD>
<TD>
<select name="dis">
<option value="" disabled selected>Välj Dis</option>
<option value="D">D</option>
<option value="SJ">SJ</option>
<option value="E">E</option>
<option value="U">U</option>
<option value="K">K</option>
<option value="T">T</option>
</select>
</TD>
</TR>
</TBODY>
</TABLE>
</form>
THIS IS THE PHP/DATABASE PROCESS
<?php
session_start();
ob_start();
include("function/conn.php"); //Databas koppling
mysql_set_charset("utf8");
$Horse_id = addslashes($_POST['Horse_id']);
$Year = addslashes($_POST['years']);
$Place = addslashes($_POST['place']);
$Event = addslashes($_POST['event']);
$Class = addslashes($_POST['class']);
$Assoc = addslashes($_POST['association']);
$Point = addslashes($_POST['points']);
$Type = addslashes($_POST['type']);
$Dis = addslashes($_POST['dis']);
//Sparar värden i variabler ifrån form
$result = mysql_query(" INSERT INTO shows
(Horse_id, years, place, event, class, association, points, type, dis)
VALUES('$Horse_id', '$Year', '$Place', '$Event', '$Class', '$Assoc', '$Point', '$Type', '$Dis') ") or die(mysql_error());
// Lägger in ny post i databasen
if ($result){ //Skicka tillbacka användaren till backend
header("location: admin.php");
}
else{
echo "Something went wrong.";
}
?>

Give the form fields array-style names, e.g.
<input type="text" placeholder="ID" name="Horse_id[]" required oninvalid="this.setCustomValidity('Ange ID')" oninput="setCustomValidity('')" size="5"/>
Then in PHP, $_POST['Horse_id'] will be an array of all the inputs; the server script can loop through them and insert them all in the DB. If you use the same name in all rows without [], $_POST['Horse_id'] will only contain the last one.

The problem is because you don't change the name'ed field of the cloned inputs and the back-end only takes the last one in most cases.
I left an example in a similar topic: Change name attribute of input/select field nested in a cloned table for dynamic form entry - Javascript

Related

jquery select change get data attribute value for each tr td in The table contains dynamically generated rows

I've created a table with two rows, with the ability to create additional rows dynamically; the problem I'm having is that I want to make the value of the last cell in any row related to the user's choice from the drop-down list in the first cell in the row.
I have code that works, but it only works on the first row correctly and repeats printing the same value in all next rows, any good suggestion would be appreciated and thank you;
my problem is here:
<script>
$('#select_acount').on('change', function() {
$('.mount').val($(this).val());
});
</script>
html code :
<td> <select class="form-control select2" id="select_acount" required>
<option value="">--الحساب--</option>
<?php
$query = "select * from sah7atmain_acouts WHERE company like '".$multi."'";
$result = mysqli_query($con,$query);
if($result) {
while($row = mysqli_fetch_assoc($result)){
?>
<?php echo '<option value="'.$row['acount_mounte'].'">'.$row['acount_name'].'</option>'?>;
<?php
}
} else{
}
?>
</select></td>
<td>
<input type="number" name="debtor[]" id="fname"class="form-control quantity arabicNumbers" onkeydown="return event.keyCode !== 69" required> </td>
<td> <input type="number" name="creditor[]" id="james" class="form-control amount arabicNumbers" onkeydown="return event.keyCode !== 69" required> </td>
<td> <input type="text" name="description[]" class="form-control" required> </td>
<td> <input type="text" name="mount[]" class="form-control mount" required> </td>
</tr>
<tr>
<td> <select class="form-control select2" required>
<option value="">--الحساب--</option>
<?php
$query = "select * from sah7atmain_acouts WHERE company like '".$multi."'";
$result = mysqli_query($con,$query);
if($result)
{
while($row = mysqli_fetch_assoc($result)){
?>
<?php echo '<option value="'.$row['acount_name'].'">'.$row['acount_name'].'</option>'?>;
<?php
}
} else{
}
?>
</select></td>
<td> <input type="number" name="debtor[]" id="fname"class="form-control quantity arabicNumbers" onkeydown="return event.keyCode !== 69" pattern="[0-9]*"required> </td>
<td> <input type="number" name="creditor[]" id="james" class="form-control amount arabicNumbers" onkeydown="return event.keyCode !== 69" pattern="[0-9]*"required> </td>
<td> <input type="text" name="description[]" class="form-control" required> </td>
<td> <input type="text" name="mount[]" class="form-control mount" id="mount" required> </td>
<td> <button type="button" id="add" class="btn btn-success"><i class="fas fa-plus"></i></button></td>
var priceval = new Array(); //Declaare array to store data
$('.testp').each(function() { //Function for dynamic class
priceval.push($(this).val()); //Fetch Values from class elements and put into the priceval array
});
instead of id use class as you can use 1 id only once in a particular page. so your code would be:
$('.select_acount').on('change', function() {
$(this).closest('tr').find('.mount').val($(this).val());
});
closest will find your nearest tr to your select button inside which it will find element with mount class and update value there

Clone Table Row with drop down not working

I am trying to clone a row from a template, with selected values. I also want to reset the template row after the clone.
$("CloneButton").click(function() {
var clonedRow = $('#rowtemplate').clone();
clonedRow.html($(clonedRow).html().replace(/#/g, index));
clonedRow.find('.project').text(project);
clonedRow.find('.billingcodeCssId').val(timeCodeID);
clonedRow.find('.billingcodeCss').text(timeCode);
$('#Maintable').append(clonedRow.find('tr'));
});
When I try to clone the table row JS Fiddle, the selector is not picking up the selector.
Whats wrong with selector, and how to clone the row with drop down with the selected values?
Try This
There will be many changes needed in your code ..
you wrote $("CloneButton").click(function() { - it misses the # ID selector - so your button click will not fire. You need to write $("#CloneButton").click(function() {
You need to set selectd attribute for both dropdown before you clone and append. You can set selected attribute using .attr("selected", true)
Below code is working fine for me. Check Working Code Snippet
$("#CloneButton").click(function() {
var drp1Value = $('#rowtemplate tr').find('select').eq(0).val();
$("option[value=" + drp1Value + "]", $('#rowtemplate tr').find('select').eq(0))
.attr("selected", true).siblings()
.removeAttr("selected");
var drp2Value = $('#rowtemplate tr').find('select').eq(1).val();
$("option[value=" + drp2Value + "]", $('#rowtemplate tr').find('select').eq(1))
.attr("selected", true).siblings()
.removeAttr("selected");
var clonedRow = $('#rowtemplate tr').clone();
$('#Maintable').append(clonedRow);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<h4 >Main Table</h4>
<table id="Maintable" >
<th>Client</th><th>Heading</th><th>Heading</th><th>Total</th><th>Delete?</th>
<tr>
<td>
<span class="project"> <select class="form-control projectcodeid" id="Records_0__SelectedProjectFromList" name="Records[0].SelectedProjectFromList"><option value="">Modeling</option>
<option value="1">Ventosanzap</option>
<option value="2">Modeling</option>
<option value="3">Xilinx ISE</option>
</select>
</span>
</td>
<td>
<input type="hidden" name="Records.Index" value="0">
<span class="billingcodeCss"> <select class="form-control timecodeDdlId" id="Records_0__SelectedBillingCodesFromList" name="Records[0].SelectedBillingCodesFromList">
<option value="">Budget-070</option>
<option selected="selected" value="5">Budget-070</option>
<option value="6">Budget-784</option>
<option value="7">Cost Center-027</option>
</select></span>
</td>
<td>
<input name="Records[0].TimeRecords[0].ID" type="hidden" value="">
<input class="meters" name="Records[0].TimeRecords[0].Meters" type="text" value="">
</td>
<td class="rowtotal">10.00</td>
<td>
<input class="bs-checkbox mt-checkbox mt-checkbox-outline deleteRow" name="Records[0].DeleteRow" type="checkbox" value="true"><input name="Records[0].DeleteRow" type="hidden" value="false">
</td>
</tr>
<tr>
<td><span class="project">
<select class="form-control projectcodeid" id="Records" name="Records[1].SelectedProjectFromList"><option value="">Xilinx ISE</option>
<option value="1">Ventosanzap</option>
<option value="2">Modeling</option>
<option value="3">Xilinx ISE</option>
</select></span>
</td>
<td>
<input type="hidden" name="Records.Index" value="1">
<span class="billingcodeCss"> <select class="form-control timecodeDdlId" id="Records_1__SelectedBillingCodesFromList" name="Records[1].SelectedBillingCodesFromList"><option value="">Bill-727 </option>
<option value="1">TIME CODE A </option>
<option selected="selected" value="2">Bill-727 </option>
<option value="3">Bill-561 </option>
<option value="4">Bill-281 </option>
</select></span>
</td>
<td>
<input name="Records[1].TimeRecords[0].ID" type="hidden" value="">
<input class="meters" name="Records[1].TimeRecords[0].Meters" type="text" value="">
</td>
<!-- added row totals rowtotalmeters-->
<td class="rowtotal">
0.00
</td>
<td>
<input class="bs-checkbox mt-checkbox mt-checkbox-outline deleteRow" name="Records[1].DeleteRow" type="checkbox" value="true"><input name="Records[1].DeleteRow" type="hidden" value="false">
</td>
</tr>
</table>
<!--*********** End Main Table-->
<hr />
<h4>Row template</h4>
<button type="button" id="CloneButton">Add Clone Row to table!</button>
<table id="rowtemplate">
<tr>
<td>
<span class="project"> <select class="form-control projectcodeid" id="Records_0__SelectedProjectFromList" name="Records[0].SelectedProjectFromList"><option value="">Default</option>
<option value="0">Null</option>
<option value="1">Ventosanzap</option>
<option value="2">Modeling</option>
<option value="3">Xilinx ISE</option>
</select></span>
</td>
<td>
<input type="hidden" name="Records.Index" value="0">
<span class="billingcodeCss"> <select class="form-control timecodeDdlId" id="Records_0__SelectedBillingCodesFromList" name="Records[0].SelectedBillingCodesFromList">
<option value="">Default</option>
<option value="0">Null</option>
<option value="">Budget-070</option>
<option value="5">Budget-070</option>
<option value="6">Budget-784</option>
<option value="7">Cost Center-027</option>
</select></span>
</td>
<td>
<input name="Records[0].TimeRecords[0].ID" type="hidden" value="">
<input class="meters" name="Records[0].TimeRecords[0].Meters" type="text" value="">
</td>
<td class="rowtotal">0.00</td>
<td>
<input class="bs-checkbox mt-checkbox mt-checkbox-outline deleteRow" name="Records[0].DeleteRow" type="checkbox" value="true"><input name="Records[0].DeleteRow" type="hidden" value="false">
</td>
</tr>
</table>
Please check the code snippet

Javascript form - different email based on choice

I am using a javascript form with a server-side processor and I want to be able to have the form go to different emails based on the dropdown. I've gotten as far as I could based on other forms but I can't seem to get the emails to go through. I have added under the option tag on the email addresses for the choices and changed the value from an overall form email to "mailTo" () I am pretty sure this is where the issue is but I don't know how to fix it.
<form action="http://www.testsite.com/cgi-sys/formmail.pl" method="post" name="hgmailer">
<input type="hidden" name="recipient" value="mailTo">
<input type="hidden" name="subject" value="Website Consult Request">
<table width="100%" border="0" cellspacing="10px" cellpadding="10px">
<tbody>
<tr>
<td>Nearest Location*</td>
<td><select id="mailTo" name"mailTo">
<option value="option1#testsite.com">Option1</option>
<option value="option2#testsite.com">Option2</option>
<option value="option3#testsite.com">Option3</option>
<option value="option4#testsite.com">Option 4</option>
</select></td>
</tr>
</tbody>
</table><p> </p>
<input type="button" value="Schedule a Consultation" onclick="hgsubmit();" class="button">
<input type="hidden" name="redirect" value="thankyou.html">
</form>
EDIT - My final code did not save previously
What you can do is add a javascript function to change the value of "recipient" to the selected email like...
function changeVal() {
var selectedVal = document.getElementById("mailTo").value;
document.getElementById("recipient").value = selectedVal;
var test = document.getElementById("recipient").value;
//alert(test);
}
<form action="http://www.testsite.com/cgi-sys/formmail.pl" method="post" name="hgmailer">
<input type="hidden" name="recipient" id="recipient" value="mailTo">
<input type="hidden" name="subject" value="Website Consult Request">
<table width="100%" border="0" cellspacing="10px" cellpadding="10px">
<tbody>
<tr>
<td>Nearest Location*</td>
<td><select id="mailTo" name"mailTo" onchange="changeVal()">
<option value="option1#testsite.com">Option1</option>
<option value="option2#testsite.com">Option2</option>
<option value="option3#testsite.com">Option3</option>
<option value="option4#testsite.com">Option 4</option>
</select></td>
</tr>
</tbody>
</table><p> </p>
<input type="button" value="Schedule a Consultation" onclick="hgsubmit();" class="button">
<input type="hidden" name="redirect" value="thankyou.html">
</form>
...I added an alert that you can comment out if you would like to test. Also I did this in javascript and not Jquery as you only asked for that.

Unable to post tag returned through document.getElementById('div').innerHTML

I am working on this form with several select elements with options Yes, No or Not applicable. It was required that whenever the user select yes option a separate date field appears next to it. I used HTML DOM document.getElementById("id").innerHTML for this date field. Everything went well but I was not able to pass the value of date to the form action page using POST method. Check this code:
<!-- javascript code -->
<script type="text/javascript">
function credit_check(name){
if(name=='YES')document.getElementById('div2').innerHTML='Date: <input type="date" name="credit_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div2').innerHTML='';
}
function employment_check(name){
if(name=='YES')document.getElementById('div3').innerHTML='Date: <input type="date" name="employment_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div3').innerHTML='';
}
</script>
</head>
<body>
<?php include("menu.inc"); ?>
<div id="main">
<table>
<form method="post" action="checkinfo.php">
<tr><td colspan=2><hr/><input type="hidden" name="consultant_id" value="<?php echo $consult_id; ?>"> </td>
</tr>
<tr align="center">
<td><b>Credit Check </b></td>
<td>
<select name="2" onchange="credit_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div2"> </div></td>
</tr>
<tr align="center">
<td><b>Employment Check :<font color='red'>*</font></b></td>
<td>
<select name="3" onchange="employment_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div3"> </div></td>
</tr>
</form>
</table>
Demo - Change function credit_check(name) to window.credit_check = function(name)
window.credit_check = function(name){
if(name=='YES') document.getElementById('div2').innerHTML='Date: <input type="date" name="credit_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div2').innerHTML='';
}
window.employment_check = function (name){
if(name=='YES') document.getElementById('div3').innerHTML='Date: <input type="date" name="employment_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div3').innerHTML='';
}
You're script wasn't loading properly,
Uncaught ReferenceError: credit_check is not defined in your console shows the error. The functions were not being defined. You can set your functions like above or reposition your code.
Put the inputs into the HTML at loading, then simply hide/show them.
<!-- javascript code -->
<script type="text/javascript">
function credit_check(name){
if(name=='YES')document.getElementById('div2').style.display = 'block';
else document.getElementById('div2').style.display = 'none';
}
function employment_check(name){
if(name=='YES')document.getElementById('div3').style.display = 'block';
else document.getElementById('div3').style.display = 'none';
}
</script>
</head>
<body>
<?php include("menu.inc"); ?>
<div id="main">
<table>
<form method="post" action="checkinfo.php">
<tr><td colspan=2><hr/><input type="hidden" name="consultant_id" value="<?php echo $consult_id; ?>"> </td>
</tr>
<tr align="center">
<td><b>Credit Check </b></td>
<td>
<select name="2" onchange="credit_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div2" style="display: none;">
Date: <input type="date" name="credit_check_date" value= "mm/dd/yyyy" />
</div></td>
</tr>
<tr align="center">
<td><b>Employment Check :<font color='red'>*</font></b></td>
<td>
<select name="3" onchange="employment_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div3" style="display: none;">
Date: <input type="date" name="employment_check_date" value= "mm/dd/yyyy" />
</div></td>
</tr>
</form>
</table>
It's also a good idea to check out jQuery, it makes this kind of stuff a lot easier to do.
Your code is already working. See http://jsfiddle.net/2wg4u6ut/
Make sure your JavaScript is in the head section of your document.
There were some minor issues in your formatting where the <form> tag belongs around the table.
You also were missing the submit button, but then it's already working.

Paypal not picking up selection choices

I have created a script for partial season ticket package sales on my music group's website. A user would select 4 concert programs and then select a date for each concert program selected. All of these selections need to post to Paypal for processing/purchasing. My "Add to Cart" button does route to Paypal, but the concert programs and dates are not being picked up. The box office people need this information. You can see the code I have here: http://jsfiddle.net/saraswati/v6Pur/66/
Here is the HTML:
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"><strong><a name="Partial">Partial</a> subscription (4 concerts), Regular Price: $87.00 (a savings of 13%)</strong>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="temp_1344946752_biz#me.com">
<input type="hidden" name="item_name" value="Partial subscription (4 concerts), Regular Price">
<input type="hidden" name="amount" value="87.00">
<input type="hidden" name="currency_code" value="USD">
<table width="90%" cellspacing="0" cellpadding="0" border="1">
<CAPTION>Please select the desired concert program and then the desired date from the pull-down menus. Then click the "Add to Cart" button.</CAPTION>
<tr id="row1" align=center>
<td><font color="#990000">Concert 1:</font></td>
<td><font color="#990000">Concert 2:</font></td>
<td><font color="#990000">Concert 3:</font></td>
<td><font color="#990000">Concert 4:</font></td>
</tr>
<tr id=row2>
<td><input type="hidden" name="os0" value="Concert 1"><body onload="ChangeDateDropList ();">
<select id="program1" onchange="ChangeDateDropList(1);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date1">
</select>
</body>
</td>
<td><input type="hidden" name="os1" value="Concert 2"><body onload="ChangeDateDropList ();">
<select id="program2" onchange="ChangeDateDropList(2);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date2">
</select>
</body>
</td>
<td><input type="hidden" name="os2" value="Concert 3"><body onload="ChangeDateDropList ();">
<select id="program3" onchange="ChangeDateDropList(3);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date3">
</select>
</body>
</td>
<td><input type="hidden" name="os3" value="Concert 4"><body onload="ChangeDateDropList ();">
<select id="program4" onchange="ChangeDateDropList(4);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date4">
</select>
</body>
</td>
</tr>
</table>
<br>
<center>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</center>
And here is the Javascript:
var progamsAndDates = {};
progamsAndDates.TUDORS = ['Sept. 15', 'Sept. 16'];
progamsAndDates.NOCHES = ['Oct. 20', 'Oct. 21'];
progamsAndDates.CHRISTMAS = ['Dec. 14', 'Dec. 15', 'Dec. 16'];
progamsAndDates.CELTIC = ['Jan. 26', 'Jan. 27'];
progamsAndDates.UNREQUITED = ['Mar. 02', 'Mar. 03'];
progamsAndDates.SECRET = ['Apr. 20', 'Apr. 21'];
function ChangeDateDropList (id) {
var programDropList = document.getElementById ("program"+id);
var dateDropList = document.getElementById ("date"+id);
var selProgram = programDropList.options[programDropList.selectedIndex].value;
// remove all dates
while (dateDropList.options.length) {
dateDropList.remove (0);
}
// add new dates
var dates = progamsAndDates[selProgram];
if (dates) {
for (var i=0; i < dates.length; i++) {
var date = new Option (dates[i], i);
dateDropList.options.add (date);
}
}
}
Again, when I click on the "Add to Cart" button, it goes to Paypal and the description reads "Partial subscription (4 concerts), Regular Price" and it picks up the Item Price, etc. However, the description should also show the selections, such as "Tudors, Sept. 15; Celtic, Jan.27; etc." I query the wisdom of you all in getting this to work. Thank you!
The variables you are passing over are not correct. You are passing over variables such as on0, os0, on1, os1. These would be correct for add to cart buttons or buy now buttons, but since you are using the cart upload method they need to be passed over like on0_1, os0_1, on1_2, and os1_2. This will correct your issue, and they should then show up.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="my_email#my_site.com">
<input type="hidden" name="item_name_1" value="Football T-Shirt">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="on0_1" value="Color">
<input type="hidden" name="os0_1" value="Red">
<input type="hidden" name="on1_1" value="Size">
<input type="hidden" name="os1_1" value="Small">
<input type="hidden" name="item_name_2" value="Notebook">
<input type="hidden" name="amount_2" value="2.00">
<input type="hidden" name="on0_2" value="Number of Pages">
<input type="hidden" name="os0_2" value="200">
<input type="hidden" name="on1_2" value="Type">
<input type="hidden" name="os1_2" value="3 Ring">
<input type="submit" value="PayPal">
</form>

Categories