Page 1 of 1
Option values
Posted: Fri Jun 15, 2007 12:17 pm
by eektech909
How can I grab the value of the selected option and make it a string?
I want to add the size with the item name in the add to cart button code.
Code: Select all
echo(" <td valign='top'><select name='selectsize' class='proddetail' tabindex='1' onChange=''>");
echo(" <option value='M'>M</option>");
echo(" <option value='L'>L</option>");
echo(" <option value='XL'>XL</option>");
echo(" </select> </td>");
and put it where $psize is
Code: Select all
echo(" <input type='hidden' name='item_name' value='" . $pname . " - " . $psize . "'>");
Posted: Fri Jun 15, 2007 1:54 pm
by RobertGonzalez
$_POST['selectsize'] on the page the form is posted to.
Posted: Fri Jun 15, 2007 3:13 pm
by eektech909
I don't send the information to another page, its needs to be used in a later part of the code in the same form.
I'm try to label a hidden input to be the product name(thats grabbed from the database), and add the product size (thats selected in the combobox) to it
Posted: Fri Jun 15, 2007 3:24 pm
by volka
If you don't want to send a new http request you have to use a client-side language like javascript.
Posted: Fri Jun 15, 2007 5:03 pm
by RobertGonzalez
So the form never submits? Or you post back to itself? Please explain which.
Posted: Mon Jun 18, 2007 1:43 pm
by eektech909
I use the information to create the add to cart code that is sent to paypal. I don't receive a response back, i'm just sending it.
Does anyone know how to assign the option value to a php string in a javascript function?
Posted: Mon Jun 18, 2007 2:06 pm
by RobertGonzalez
Javascript = Client side.
PHP = Server side.
To get data from the client to the server you need to submit a request (ie form post or querystring page request).
Posted: Mon Jun 18, 2007 2:52 pm
by eektech909
Would it be best to post the form to the same page then send the request to paypal after that?
Posted: Mon Jun 18, 2007 3:20 pm
by RobertGonzalez
The only way you're going to capture information in a form is to post it, so I would say yeah, post your form, get the posted data, then use it.
Posted: Mon Jun 18, 2007 10:43 pm
by eektech909
How do I go about posting the form to the same page, and then posting that information to an external server?
I've been trying to to assign a variable in the onchange field to the selected option. Can that work?
Posted: Tue Jun 19, 2007 10:22 am
by RobertGonzalez
onChange is something that occurs client side. That means the browser sees it, but the server never does. You can use that, but you are still going to need a page to post to. You can always set the form action attribute value to the name of the page you are on, then check for post in that page and if there are post values, use those to cURL out to the site you want to post to.
Posted: Wed Jun 27, 2007 10:28 pm
by eektech909
Alright... i'm pulling my hair out on this.
Heres the code.
Code: Select all
echo("<tr>");
echo("<td>");
echo("<br /><span class='othercontenttitle'>APPAREL</span><br />");
echo("<table width='690' align='0' cellpadding='0' cellspacing ='0' class='contentpdetailbg' align='center'>");
echo("<tr><td class='othercontent'>");
$prid = ($_GET['pid']);
$prsku = ($_GET['psku']);
$productdetail = mysql_query("SELECT * FROM products WHERE prod_id ='" . $prid . "' && prod_sku='" . $prsku . "'");
$count = mysql_num_rows($productdetail);
while ($detail=mysql_fetch_array($productdetail)){
$imgcatid = ($detail["prod_id"]);
$imgsku = ($detail["prod_sku"]);
$pname = ($detail["prod_name"]);
$pdesc = ($detail["prod_desc"]);
$price = ($detail["prod_price"]);
echo("<form name='form' target='paypal' action='https://www.paypal.com/...' method='post'>");
echo("<table width='650' border='0' align='center' cellpadding='0' cellspacing='5'>");
echo(" <tr>");
echo(" <td colspan='3' class='proddetailtitle'>");
echo(" Product Details </td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td width='400' rowspan='6'><img src='images/full/" . $imgcatid . "_" . $imgsku . ".jpg' border='0'></td>");
echo(" <td height='47' colspan='2' valign='top' class='contentheader'>" . $pname . "</td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td height='142' colspan='2' valign='top' class='proddetail'>" . $pdesc . "</td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td height='29' valign='top' class='proddetail'>Size:</td>");
echo(" <td valign='top'><select name='selectsize' class='proddetail' tabindex='1' onChange=''>");
echo(" <option value='" . $pname . " - M' selected='selected'>M</option>");
echo(" <option value='" . $pname . " - L'>L</option>");
echo(" <option value='" . $pname . " - XL'>XL</option>");
echo(" </select> </td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td height='33' valign='top' class='proddetail'>Quantity:</td>");
echo(" <td valign='top'><input name='qtyfield' type='text' class='proddetail' tabindex='2' value='1' size='10' />");
echo(" </td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td height='25' valign='top' class='proddetail'>Price:</td>");
echo(" <td valign='top' class='proddetail'>$ <b>" . $price . "</b>");
echo(" </td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td width='72' valign='top' class='proddetail'><p>Processing:</p> </td>");
echo(" <td width='158' valign='top' class='proddetail'>ships within 2 business days. orders after 3pm will be processed next day</td>");
echo(" </tr>");
echo(" <tr>");
echo(" <td> </td>");
echo(" <td colspan='2'>");
echo(" <div align='center'>");
echo(" <input type='image' src='images/add_to_cart.gif' border='0' name='submit' alt='Stencil Tee'>");
echo(" <img alt='' border='0' src='https://www.paypal.com/..' width='1' height='1'><br />");
echo(" <input type='hidden' name='add' value='1'>"); ****I NEED THE QUANTITY FROM QTYFIELD HERE INSTEAD OF 1****
echo(" <input type='hidden' name='cmd' value='_cart'>");
echo(" <input type='hidden' name='business' value='accountname'>");
echo(" <input type='hidden' name='item_name' value='PRODUCT'>"); ****I NEED THE SELECTED OPTION VALUE HERE****
echo(" <input type='hidden' name='item_number' value='" . $imgcatid . "_" . $imgsku . "'>");
echo(" <input type='hidden' name='amount' value='" . $price . "'>");
echo(" <input type='hidden' name='no_shipping' value='0'>");
echo(" <input type='hidden' name='no_note' value='1'>");
echo(" <input type='hidden' name='currency_code' value='USD'>");
echo(" <input type='hidden' name='lc' value='US'>");
echo(" <input type='hidden' name='bn' value='PP-ShopCartBF'>");
echo(" </div></td>");
echo(" </tr>");
echo("</table>");
echo("</form>");
}
echo("</td></tr></table>");
echo("</td>");
echo("</tr>");
I need to pull some information from the form to submit to paypal
There noted with ****
Posted: Thu Jun 28, 2007 11:35 am
by RobertGonzalez
Where is the QUANTITY and PRODUCT values being set?
Posted: Thu Jun 28, 2007 9:04 pm
by eektech909
They decided to drop the QUANTITY option and set it to 1 so never mind that
The PRODUCT is the value of the 'selectsize' selected option (drop-down).
I'm need to get the value of the drop-down box WITHOUT posting the form to a page on wellbornclothing.com..
If its a MUST that I post the form to the same page... (i know how to get the values from the post) how do I send that info to paypal after the page refreshes?
Posted: Fri Jun 29, 2007 11:16 am
by RobertGonzalez
eektech909 wrote:I'm need to get the value of the drop-down box WITHOUT posting the form to a page on wellbornclothing.com..
Javascript. But you are seriously going to need some contingency plans for folks that have it turned off or disabled.
eektech909 wrote:If its a MUST that I post the form to the same page... (i know how to get the values from the post) how do I send that info to paypal after the page refreshes?
cURL, using the data you already have. Or the Paypal API. They have some pretty good documentation on their webservices.