homepage Welcome to WebmasterWorld Guest from 54.166.105.24
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Yahoo to Paypal conversion - JS Newbie (Part II)
How do I convert from Yahoo to Paypal Shopping cart (Cont)
pctechguy




msg:1487890
 2:20 pm on Apr 16, 2003 (gmt 0)

This script is the type of paypal cart Im looking for (see previous post [webmasterworld.com]) - the parts are seperated by //#B

//4B
ok, with this form the 'vAmount' is the same as "total2" (or 1), right? Now, I guess item_name can be anything unigue. Does anything have to be set up on paypal that references this (or any
other value besides email)?

<line breaks added to stop side scrolling>
<script LANGUAGE="JavaScript">
function PayPal(vQty, vItem, vAmount){
popup = window.open('h**ps://www.paypal.com/cart/add='+vQty+'&business=email@deleted.com
&item_name='+vItem+'&amount='+vAmount+'&return=deleted.com&cancel_return=deleted.com',
'cartwin','width=600,height=400,scrollbars,location,resizable,status')
}
</script>

//5B
ok, here is an item from that page...the thing is, it doesnt have options that change values... what I need to know is how to change this so that is takes the value of "total2" and puts it into the

<!--line breaks added-->
//'h**ps://www.paypal.com/cart/add='+vQty+'&business=email@deleted.com&
item_name='+vItem+'&amount='+vAmount+'&return=deleted.com&cancel_return=deleted.com',
'cartwin','width=600,height=400,scrollbars,location,resizable,status'

line. Seeing as how this script uses single quotes and the other uses double quotes, I think it may be a little harder than just changing 'vAmount' to 'total2', but maybe not. Any help? Not even sure which parts below are the script and which are the form are are they the same thing?

<form name="frm54">
<div align="center"><center>
<table border="0" cellSpacing="0" cellpadding="0" width="90%">
<tr>
<td vAlign="top"><center>
<img
src="redcdrw.jpg" width="320" height="320"></center></td>
</tr>
<tr>
<td vAlign="top" width="100%"><strong><font face="Arial, Helvetica" size="2"
color="#0080C0">(CD-104-218) Red CDRW</font><font face="Arial, Helvetica" size="2" color="#2599BA"><br>
</font></strong><font face="Arial, Helvetica" size="2">
<br>
</font><br>
<font face="Arial, Helvetica" size="2" color="#000000"><b></b>

<b>Sales Price:</font>
<font color="#FF0000"><font face="Arial, Helvetica" size="2">$
60.00</font></font></b></td>
</tr>
<tr>
<td vAlign="top"><font face="Arial" size="2"><strong>Qty:</strong> 1
<script LANGUAGE='JavaScript'>
<!--
var vTotal54 = 60.00
function Price54(frm54){vTotal54 = 60.00}
//-->
</script>
</font><font face="Arial, Helvetica" size="-1">&nbsp;
<input type="hidden"
name="B3" value=" Add "
onclick="parent.order ('(CD-104-218) Red CDRW',
60.00,
1.00,
document.frm54.
quantity[document.frm54.quantity.selectedIndex].value,
'G0')"></font>

[red][1]<!--line breaks added-->[/1][/red]
&nbsp;<a href="#" onclick="PayPal(1,'(CD-104-218) Red CDRW','60.00')"><img src="addpaypal.gif" border="0" width="69" height="24" align="absmiddle"></a>&nbsp;<a href="#" onclick="window.open('https://www.paypal.com/cart/display=1&
business=email@deleted.com','cartwin','width=600,height=400,scrollbars,location,
resizable,status');"><img src="viewpaypal.gif" border="0" width="69" height="24" align="absmiddle"></a></td>
</tr>
</table>
</center></div>
</form>

[edited by: tedster at 7:14 pm (utc) on April 16, 2003]

 

pctechguy




msg:1487891
 12:55 am on Apr 17, 2003 (gmt 0)

Sorry for clogging the boards with long posts like that...I guess all Im really asking is how to get the "total2" variable from the first script into a paypal script like the one in the second post. Do I just replace the vTotal with total2 in the 2nd one and replace the yahoo portion of the first script with the revised paypal script or is it more complicated than that?

tedster




msg:1487892
 1:40 am on Apr 17, 2003 (gmt 0)

Here's the way I see it. Both carts (PayPal and Yahoo) are relatively complex code. Now I can't read javascript as if it were English, and so I can't be sure what each cart's script is doing without a lot of headache.

I appreciate that you probably already have a HUGE headache from plowing through all this script after only 2 weeks acquaintance with JS. But you do suspect that you see what the change should be.

Can you set up a test environment, try out your idea and see how it works? Kick the tires on your new code pretty hard.

See, if I just say yes or no to your question, I could easily have missed some detail. So you'll need to test anyway.

You can't trust me on a code-specific question like this, which depends very much on the original code writer's way of doing things. And I'm very hesitant to give you either a yes or a no in any case, because there's a whole mess of work involved in untangling this thing.

Hope you understand.

pctechguy




msg:1487893
 11:20 am on Apr 17, 2003 (gmt 0)

OK, Ive figured this much out... I have to use

<form target="paypal" action="https://www.paypal.com/cgibin/webscr" method="post" class="xgear" style="FONT-SIZE: 8pt" name="calculate">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="deleted@name.com">
<input type="hidden" name="item_name" value="Custom AMD System"
<input type="hidden" name="item_number" value="420420">
<input type="hidden" name="amount" value="99999.99">
<input type="hidden" name="tax" value="0.00">

to use paypal, so as far as thats concerned, I dont need javascript, except that I want to take that "total2" value from the configurator script :

<input style="COLOR: #0000ff; FONT-FAMILY: Arial" readOnly size="10" value="$499.00" name="total2">

Also, referred to in the javascript in the document head:

function get_total(){
//edit here for starting price
var tmp = 0 * 1;

//do not edit
var type = "cas,cpu";
var type_array = type.split(",");

for(loop = 0; loop < type_array.length; loop++){
var name = eval('document.calculate.' + type_array[loop] + '.value.split(",")');
name[0] = name[0] * 1;
tmp = tmp + name[0];

}

document.calculate.total1.value = "(+" + showpos(tmp) + ")";
document.calculate.total2.value = "$" + showpos(tmp);

}

Which then it dawned on me that I can actually use either "total2" from the form OR the get_total() function from the JS above. The question I have is how do I get one of those values into the

<input type="hidden" name="amount" value="99999.99">

to replace the "99999.99" with the correct value (total2 or get_total())?
Thanks for the help.

pctechguy




msg:1487894
 11:23 am on Apr 17, 2003 (gmt 0)

btw, I tried just substituting "99999.99" for the following with no success:

"total2"
'total2'
total2
"javascript:get_total()"
'javascript:get_total'
javascript:get_total

pctechguy




msg:1487895
 1:20 pm on Apr 17, 2003 (gmt 0)

I believe I figured it out.
I added the following

document.calculate.amount.value = document.calculate.total2.value

right under

document.calculate.total2.value = "$" + showpos(tmp);

So when I submit, the value for

<input type="hidden" name="amount" value="499">

is changed to whatever total2 is in the form. Hope this helps some future newbies :-)

pctechguy




msg:1487896
 5:03 pm on Apr 17, 2003 (gmt 0)

Ok, one more question, ten I think Im done with this problem...Im trying to figure out how to email myself the contents of the form as well as send what I need to paypal...do I just add an additional action="mailto:email@mail.com" to the <form> thats already there or do I encase the entire form in another form that has the mailto action?
(eg:

<form action="mailto:me@me.com" method="post" enctype="text/plain">
<form target="paypal" action="https://www.paypal.com/cgibin/webscr" method="post" class="xgear" style="FONT-SIZE: 8pt" name="calculate">
<input type="hidden" name="cmd" value="_cart">
.....blahlbahlbah.....
</form>
</form>

)
or would I

<form target="paypal" action="https://www.paypal.com/cgibin/webscr" method="post" class="xgear" style="FONT-SIZE: 8pt" name="calculate">
<input type="hidden" name="cmd" value="_cart" action="mailto:me@me.com" method="post" enctype="text/plain">
....blahblah....
</form>

? Thanks.

tedster




msg:1487897
 5:58 pm on Apr 17, 2003 (gmt 0)

Doesn't PayPal already send you an acknowledgement copy? I though that was included in what they do.

Anyway, about your first example, form elements cannot be nested, so that's out.

Also, just using mailto: does not give very useful results, but instead gives you raw form data. If you go that route, you would probably want to use a second attribute to give you a more readable formatting - something like action="mailto:me@me.com" enctype="text/plain". And even then, you're depending on the client machine having a properly configured email client for the form's action to execute. Not a good idea.

There are loads of standard CGI scripts that turn form data into an email, such as formmail and aspmail. But your overriding issue here is that you want to take two actions with one form.

You're probably going to need some form of server-side CGI scripting - the form itself has an action that submits to your server. Then your CGI script on the server needs to take two actions with the form data.

I'd suggest asking server side questions over in the CGI Scripting Forum [webmasterworld.com] for the best input.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved