codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Need hosted_button_id value from PayPal generated code  n4ows at 18:53 on Wednesday, September 09, 2009
 

Maybe I'm going about this all wrong, but I need to find some way to get the hosted_button_id value into my database along with other information related to the particular item. The only way I can think to do this is to copy the PayPal generated html code into a textarea and then find the input tag with the hosted_button_id and pull that name/value pair to get the value and then place that value into an input text field.

I found a javascript somewhere that will parse through line at a time, stripping out all the html code and then I added code to parse the name/value of the line I want. It works fine at localhost on FireFox, but won't work at all when I move it up to the server. I keep getting an undefined value for the id. I think I'm going about this all wrong anyway, so I'd really appreciate some help. JavaScript is not my strongest language by any means. I'm kind of on a deadline here so sooner would be better than later if at all possible.

Code follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>hosted_button_id for PayPal</title>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function PayPalID(myString) {
//alert(myString);
var strValidChars = "0123456789";
var mySplitResult = myString.split(" ");
var PayPal = "";
for (var i in mySplitResult) {
//alert( mySplitResult );
var split2 = mySplitResult;
var mySplit2 = split2.split("=");
if (mySplit2[0] == "value") {
//alert(mySplit2[0]+"\n"+mySplit2[1]);
var ppID = mySplit2[1];

for (var j=0; j < len; j++) {
strChar = ppID.charAt(j);
if (strValidChars.indexOf(strChar) == -1) {
blnResult = false;
} else {
PayPal = PayPal + ppID.charAt(j);
}
}
}
}
//alert("PayPal: "+PayPal);
return (PayPal);
}
function Del(Word) {

hostedLen = "";
a = Word.indexOf("<");
b = Word.indexOf(">");
len = Word.length;
c = Word.substring(0, a);
var aa = a;
var bb = b + 14;
if(b == -1) {
b = a;
}
d = Word.substring((b + 1), len);
Word = c + d;
tagCheck = Word.indexOf("<");
if (tagCheck == 2) {
hostedLen = Word.substring(aa,bb);
id = PayPalID(hostedLen);
}
if(tagCheck != -1) Word = Del(Word);
return id;
}
function Check() {
ToCheck = document.form.FindPayPalID.value;
Checked = Del(ToCheck);
//document.form.paypal.value = Checked;
document.newad.PayPalID.value = Checked;
//alert("This form is not set to submit anywhere so you will stay here. But please notice that the text box's contents have been \"filtered\".");
return false;
}
// End -->

</SCRIPT>
</head>
<body>

<form action="/forum/some.html" method="post" name="form" onSubmit="return Check()">
<div align="center">
<table>
<tr>
<th> Get PayPal ID:
<a href="https://www.paypal.com/" target="_blank" />PayPal Login</a><br />
</th>
</tr>
<tr>
<td style="text-align:left;">
<textarea cols="50" rows="5" name="FindPayPalID">








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Need some help with javascript code in Unity!
•  Re: Perl - Read and Write output file
•  Re: Math.ceil depending on the number of decimal places
•  Re: drag from panel to panel..
•  Re: date of birth validation using java script-very urgent
•  Re: help me how to execute a linux shell script file(.sh file ) in perl
•  Save up to 80% on SSL Certificates, RapidSSL Certificate @ $ 11.00/yr.
•  help me
•  Re: substitute of goto in java???


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010