...

View Full Version : Need help in making the function thats tied to a...



MoreBloodWine
11-12-2010, 01:15 AM
I was wondering if someone could help me make this function that's tied to a HTML select work on an <imput type="image">.

Ideally what I would like to do is tie everything to the <input type="image"> , right now the way the code works is that when I choose yes or no the image on the <img src=""> changes. So basically when I choose yes or no in the select what I would like the image source to change for the <input type="image"> assuming it's possible.

Ty...

See my demo page for where I have it working on an img src but not an input which is what I really want.

Here's the link again to my testing / demo page: http://www.myu2sig.com/stellardonations/buttontype.php

Now for all of the code that produces what you see on said page.


<script type="text/javascript">
function showimage(t){
if (!document.images)
return;
document.images[t.getAttribute("name").replace("select","pics")].src=t.options[t.selectedIndex].id
}
</script>

Regular Image using: < img name="firstpics" src="/stellardonations/paypaldonate.gif"><br />
<img name="firstpics" src="/stellardonations/paypaldonate.gif">

<br /><br />

Input Image using: < input type="image" src="/stellardonations/paypaldonate.gif" border="0" name="submit" ><br />
<input type="image" src="/stellardonations/paypaldonate.gif" border="0" name="submit">

<br /><br />

<select name="firstselect" onChange="showimage(this)">
<option id="/stellardonations/paypalsubscribe.gif" value="Yes">Yes</option>
<option selected="selected" id="/stellardonations/paypaldonate.gif" value="No">No</option>
</select>

<br /><br />

No = Donate<br />
Yes = Subscribe

Old Pedant
11-12-2010, 01:36 AM
I *assume* that your <input type=image> is in a <form>, yes?

So:


<form>
...
<input type="image" src="/stellardonations/paypaldonate.gif" border="0" name="Submit" />
...
<select name="firstselect" onchange="this.form.Submit.src=this.value;">
<option value="/stellardonations/paypalsubscribe.gif">Yes</option>
<option selected value="/stellardonations/paypaldonate.gif">No</option>
</select>
...
</form>


Some browsers don't allow id's on <option>s. And in any case the code is much easier if you just use value="...the image location...", as you can see.

Also, you shouldn't name a <form> field "submit" or "action", as that can mess up some scripting (probably not in this case, but a good idea to avoid it). You *and* use "Submit" and "Action", as of course JS is case sensitive.

If you insist on using ID's in the <option>, then it's only a tiny more code:


<select name="firstselect"
onchange="this.form.Submit.src=this.options[this.selectedIndex].id;">


Okay?

MoreBloodWine
11-12-2010, 02:01 AM
I applied it to the relevant code where it's meant to be used on my site and the outputted image doesn't change for the <input type="image">.

Check out eojmarket.com and look down the left side and you'll see a donations tracker. What should happen is that when you select yes the Donate button should change to a Subscribe button but it doesn't.

The tracker code was part of something I paid for and modified as needed so I can't post full files but this is everything you should need to figure out whats going on but like I said ideally what should be happening is that when a user selects Yes the image to submit the form should change to Subscribe and if they change it back to No it should change back to a donate button.

Anyway, here's that code...


echo '
<script type="text/javascript">
function confirmation(){
var respConfirmation = confirm(
"Please Confirm Before Proceeding !" +
"\n\n" +
"Display Name: " + document.forms["paypal"]["os0"].value +
"\n" +
"Donation Amount: $" + document.forms["paypal"]["amount"].value +
"\n" +
"Repeat this Donation Monthly: " + document.forms["paypal"]["firstselect"].value +
"\n\n" +
"Click Ok to Proceed or Cancel to Make Changes."
);
if (respConfirmation == true){
return true;
}else{
return false;
}
}

function showimage(t){
if (!document.images)
return;
document.images[t.getAttribute("name").replace("select","pics")].src=t.options[t.selectedIndex].id
}
</script>
';

global $context;

$br = strtolower($_SERVER['HTTP_USER_AGENT']);

if(ereg("msie", $br)) {
if ($test_ipn == 1) {
echo '
<form name="paypal" style="display: inline;" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top" onSubmit="return confirmation()">
<hr width="75%" />
<P class="stellarwebsolutions" style="padding: 0px 0px 4px 0px; line-height: 16px;" align="left">
Display Name: <input type="text" name="os0" value="'.$context['user']['name'].'" maxlength="25" style="vertical-align: middle; color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 58.5%;">
<input type="hidden" name="on0" value="Username">
Donation Amount: $<input type="text" name="amount" value="0.00" maxlength="25" style="vertical-align: middle; color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 45%;">
Repeat this Donation Monthly:
<select name="firstselect" onchange="this.form.Submit.src=this.options[this.selectedIndex].id;">
<option id="./U2Signatures//stellardonations/paypalsubscribe.gif" value="Yes">Yes</option>
<option selected="selected" id="./U2Signatures//stellardonations/paypaldonate.gif" value="No">No</option>
</select>
</P>
';
} else {
echo '
<form name="paypal" style="display: inline;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" onSubmit="return confirmation()">
<hr width="75%" />
<P class="stellarwebsolutions" style="padding: 0px 0px 4px 0px; line-height: 16px;" align="left">
Display Name: <input type="text" name="os0" value="'.$context['user']['name'].'" maxlength="25" style="vertical-align: middle; color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 58.5%;">
<input type="hidden" name="on0" value="Username">
Donation Amount: $<input type="text" name="amount" value="0.00" maxlength="25" style="vertical-align: middle; color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 45%;">
Repeat this Donation Monthly:
<select name="firstselect" onchange="this.form.Submit.src=this.options[this.selectedIndex].id;">
<option id="./U2Signatures//stellardonations/paypalsubscribe.gif" value="Yes">Yes</option>
<option selected="selected" id="./U2Signatures//stellardonations/paypaldonate.gif" value="No">No</option>
</select>
</P>
';
}
} else {
if ($test_ipn == 1) {
echo '
<form name="paypal" style="display: inline;" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top" onSubmit="return confirmation()">
<hr width="75%" />
<P class="stellarwebsolutions" style="padding: 0px 0px 4px 0px; line-height: 16px;" align="left">
Display Name: <input type="text" name="os0" value="'.$context['user']['name'].'" maxlength="25" style="color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 59.5%;">
<input type="hidden" name="on0" value="Username">
Donation Amount: $<input type="text" name="amount" value="0.00" maxlength="25" style="color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 46%;">
Repeat this Donation Monthly:
<select name="firstselect" onchange="this.form.Submit.src=this.options[this.selectedIndex].id;">
<option id="./U2Signatures//stellardonations/paypalsubscribe.gif" value="Yes">Yes</option>
<option selected="selected" id="./U2Signatures//stellardonations/paypaldonate.gif" value="No">No</option>
</select>
</P>
';
} else {
echo '
<form name="paypal" style="display: inline;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" onSubmit="return confirmation()">
<hr width="75%" />
<P class="stellarwebsolutions" style="padding: 0px 0px 4px 0px; line-height: 16px;" align="left">
Display Name: <input type="text" name="os0" value="'.$context['user']['name'].'" maxlength="25" style="color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 59.5%;">
<input type="hidden" name="on0" value="Username">
Donation Amount: $<input type="text" name="amount" value="0.00" maxlength="25" style="color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 46%;">
Repeat this Donation Monthly:
<select name="firstselect" onchange="this.form.Submit.src=this.options[this.selectedIndex].id;">
<option id="./U2Signatures//stellardonations/paypalsubscribe.gif" value="Yes">Yes</option>
<option selected="selected" id="./U2Signatures//stellardonations/paypaldonate.gif" value="No">No</option>
</select>
</P>
';
}
}
?>
<input type="image" src="./U2Signatures/stellardonations/paypaldonate.gif" border="0" name="submit">
</form>

Ps; The reason I'm using ID's is because of the alert / confirmation that comes up when the user submits the form. If I use values the full image paths are printed in the message vs Yes or No like I have in the values now.

Edit: I would ask that anyone helping please reply in a find this and replace with this manner given the amount of code and what should be a small fix / hack.

Old Pedant
11-12-2010, 02:33 AM
Well, I will be durned. I never knew that an image button can't be referenced by name like that.

My fix is simple. Give it an id.


<select name="firstselect" onchange="document.getElementById('ppimg').src=this.options[this.selectedIndex].id;">
<option id="http://www.eojmarket.com/U2Signatures/stellardonations/paypalsubscribe.gif" value="Yes">Yes</option>
<option selected="selected" id="http://www.eojmarket.com/U2Signatures/stellardonations/paypaldonate.gif" value="No">No</option>
</select>
...
<input type="image" name="submit" id="ppimg"
src="http://www.eojmarket.com/U2Signatures/stellardonations/paypaldonate.gif" border="0">


You don't have to have the full image urls in there. I just put them there so I could test it locally on my machine.

My head hurts. Very strange! And for once, FF and MSIE agreed.

MoreBloodWine
11-12-2010, 03:04 AM
I could kiss you lol, looks like were golden.

The input image now change based on the selects value !

+1

MoreBloodWine
11-12-2010, 03:33 AM
I had this marked as solved but I actually was wondering if it would be possible to take this one step further. Would it be possible to modify the below function in a way that based on the select value the following function is used when the form submits ?

function printDonationButton($item_number,$comments=0)
{
global $currency_code;
global $site_cert_id, $site_sandbox_cert_id;
global $business, $use_encryption;
global $global_anonymous, $notify_url, $return, $test_ipn;

$hash = array('cmd' => '_xclick',
'business' => $business,
'cert_id' => $site_cert_id,
'currency_code' => $currency_code,
'item_name' => 'Donation for eojmarket.com',
'item_number' => $item_number,
'notify_url' => $notify_url,
'return' => $return,
//'lc' => 'US',
);

That's the normal function used for regular donations which should be tied to No / Donate button. Well, when Yes is selected and the Subscribe button / image is shown the function used should be a different one which I'm still trying to figure out since changing _xlick to _s-xclick doesn't work and AFAIK _s-xclick is used for subscriptions.

If I need to provide more code I can but it would have to be with a singular dedicated person via PM who knows what their doing. I only say that because I can share full files but again it would have to be with a singular dedicated person.

Preferrably Old Pedant.

Old Pedant
11-12-2010, 07:54 PM
??? Sorry, I don't get that.

When the form submits, it goes directly to paypal. It says so:

<form ... action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" ...>

So how can "the following function is used when the form submits" if the form submits to PayPal and not to your site???

Or are you talking about this:

<input type="hidden" name="notify_url" value="http://www.myu2sig.com/stellardonations/smf-ipn.php">
???

That is, the page that PayPal goes to after the donation is processed?

MoreBloodWine
11-12-2010, 10:00 PM
As far as I understand it when the form submits it goes to PayPal but runs that function before leaving the site. If I understand the way this tracker works it uses the function to tell what information gets passed to PayPal. So ya, I think before it leaves my site it runs that function.

Either way to simplify what I'm asking... is it possible to write in PHP / JS or whatever a statement that says if the selected value on the drop box reads Yes run function a else run function b.

I could be wrong in how this tracker works but it's work a shot.

Old Pedant
11-12-2010, 10:21 PM
when the form submits it goes to PayPal but runs that function before leaving the site
I don't see how. You could only do that by using a document.unload that would invoke the PHP code via AJAX or similar. And then the PHP code couldn't possibly affect the <form> contents that are POSTed to PayPal.

I think that code does just what it says: It prints the PayPal donate button on your Web page for you.

Yeah...looking at it closer, it's obvious that's exactly what it does.

So you want it to change from _xlick to _s-xclick and back? Trivial.



<select name="firstselect"
onchange="document.getElementById('ppimg').src=this.options[this.selectedIndex].id;
this.form.cmd.value=this.selectedIndex==0?'_s-xclick':'_xclick';">

But why stop there?


<select name="firstselect"
onchange="document.getElementById('ppimg').src=this.options[this.selectedIndex].id;
this.form.cmd.value=this.selectedIndex==0?'_s-xclick':'_xclick';
this.form.item_name.value=this.selectedIndex==0?'Subscription for eojmarket.com':'Donation for eojmarket.com';" >

But don't do that last one if it messes up the tracking, of course.

MoreBloodWine
11-12-2010, 10:27 PM
I don't see how. You could only do that by So you want it to change from _xlick to _s-xclick and back? Trivial.


Ya, I pretty much want to change the _xclick to _s-xclick if Yes is chosen in the select since as I understand it _s-xclick is what PayPal uses for the subscription process. I'm sure there's more to it than that but I wont know until I / we figure the bit out about changing _xclick ot _s-xclick is Yes is selected on the drop box and then using _xclick by default or switching back ot it should a user choose Yes and then change it back to no which is the selects default value. The function is what tells paypal to grab or some thing so I don't really know... at this point aside from passing you full files to look at this is more of a hunt and peck thing I guess.

Old Pedant
11-12-2010, 10:32 PM
Ummm...



I wont know until I / we figure the bit out about changing _xclick ot _s-xclick is Yes is selected on the drop box ...

And in what way does the code I just showed you *NOT* do that???

MoreBloodWine
11-12-2010, 10:36 PM
Ummm...


And in what way does the code I just showed you *NOT* do that???

Sorry if I made it sound like it didn't, I was just saying ya that's what I wanted it to do heh.

Also, it would appear that it does work but I get the following error when processing with _s-xclick so there must be info missing from the function or something for it to process as a subscription instead of a regular donation.

Some required information is missing or incomplete. Please correct your entries and try again.

To fix this problem I'll have to go to the codes author to figure this out since I don't know what would be missing that PayPal's looking for to process as a subscription.

Also, for arguments sake whats the "and why stop there" code do ? I didn't plug it in because you said it could cause issues with the tracker which it may very well do but since I have it in Sandbox mode I could just plug n play it to test.

MoreBloodWine
11-12-2010, 10:47 PM
I see what the other code does now heh, sorry if I seem dumb today... had a long day and lack of sleep the past week. Changing the item number wont hurt it because that's for the end users benefit. So I have to thank you for that touch, I never even considered that but really like it ;-)

So +1 again for you in my book ;-)

Either way it looks liek I'm golden now except for the error I get at PayPal when I try to process with _s-xclick that says something about missing info. I'll get to the code author and see what they have to say.

Old Pedant
11-12-2010, 10:51 PM
I suspect that PayPal expects info about the number of months/weeks/years that the subscription is to run when you tell it you want a subscription.

MoreBloodWine
11-12-2010, 10:58 PM
I suspect that PayPal expects info about the number of months/weeks/years that the subscription is to run when you tell it you want a subscription.

That actually could very well be the case because I recall when playing around with buttons when I was looking for images it asked what sort of subscription I wanted. In the case of my site it would be a month to month thing until the user cancels it. I still wouldn't know how to code that missing info. In any case I sent a mail off to the codes author asking if they knew what was missing. But I'll bring that up when they get back to me since I think that may very well be the case of the error.

Old Pedant
11-12-2010, 11:03 PM
Ummm....I think there is something VERY WRONG here!!!

Look:
https://www.x.com/docs/DOC-1332

You do *NOT* want _s-xclick!!!!

And I *VERY* much wonder if you are being suckered by those donation-tracker people! Because those docs *CLEARLY* say that _xclick is a PURCHASE whereas _donations is for donations!!!!

Anyway, *IF* you really want to hassle with subscriptions--and it looks like it's a lot of work!--then look on that page for Table 6. HTML Variables for Subscribe Buttons

But aside from all this, if you still want to use those "donation tracker" people, then you will need to ask them what they require for a subscription-that-isn't-a-donation, since clearly PayPal doesn't directly support subscriptions by donation.

Old Pedant
11-12-2010, 11:12 PM
Ahhh...now I get it! A paypal DONATE is only really legal for CERTIFIED non-profit institutions. You have to apply to paypal and include your 501c3 (in the USA) paperwork. So a "donate" to a non-certified site is treated as a payment, not a donation. And the _xclick and _xclick-subscriptions are what you need. Read the docs. It's all in there.

MoreBloodWine
11-12-2010, 11:21 PM
Ahhh...now I get it! A paypal DONATE is only really legal for CERTIFIED non-profit institutions. You have to apply to paypal and include your 501c3 (in the USA) paperwork. So a "donate" to a non-certified site is treated as a payment, not a donation. And the _xclick and _xclick-subscriptions are what you need. Read the docs. It's all in there.

Thx for that and reading now, well will be in a min... in any case the error is still probably because of the missing term of the sub. As for _xclick-subscriptions. I found that but something I read said _s-xclick is whats being used now. In either case I'll see what I can find on those docs assuming I understand any of it heh.

MoreBloodWine
11-12-2010, 11:26 PM
Ps; Here's what comes up when using _xclick-subscriptions

Sorry your last action could not be completed

If you were making a purchase or sending money, we recommend that you check both your PayPal account and your email for a transaction confirmation after 30 minutes.

If you came to this page from another website, please return to that site (don't use your browser's Back button) and restart your activity.

If you came from PayPal's website, click the PayPal logo in the upper-left corner to return to our home page and restart your activity. You might have to log in again.

Old Pedant
11-12-2010, 11:35 PM
Yes, because as I said--and as the PayPal docs there clearly show--you *MUST* give the recurrence interval of the subscription, the number of recurrences, and whether the user gets auto-billed or not.

I will say it again, look at Table 6. HTML Variables for Subscribe Buttons

Quite frankly, unless you are likely to get a lot of subscriptions, I wouldn't muck with them. But that's up to you.

MoreBloodWine
11-12-2010, 11:44 PM
Yes, because as I said--and as the PayPal docs there clearly show--you *MUST* give the recurrence interval of the subscription, the number of recurrences, and whether the user gets auto-billed or not.

I will say it again, look at Table 6. HTML Variables for Subscribe Buttons

Quite frankly, unless you are likely to get a lot of subscriptions, I wouldn't muck with them. But that's up to you.

I'm actually reading it now and as far as the option itself goes, sure I could forget it but I wanted to add it to give people the option.

Old Pedant
11-12-2010, 11:52 PM
It does occur to me that you probably could put all the subscription fields into the <form> all the time!!! If you aren't doing a subscription, they should get ignored.

But if you can't do that, it would probably be easier to have two separate <form>s and have the <select> actually in a *third* form that would then choose between the two.

That is, you'd just hide the inactive one.

Old Pedant
11-12-2010, 11:53 PM
Last suggestion for the day: Why not get up and running without the subscriptions, so at least you could start collecting money? <grin/>

Later, you could go back in and add the extra ugly stuff for subscriptions.

MoreBloodWine
11-13-2010, 12:01 AM
Last suggestion for the day: Why not get up and running without the subscriptions, so at least you could start collecting money? <grin/>

Later, you could go back in and add the extra ugly stuff for subscriptions.

I'm already up and running as it is with your previous help and have received some funds already (not since last month). So really all that's left besides boring site maint is this lol.

On the note of that doc, I'm not quite getting it all, I tried to make a button to see what the code looks like but they're all encrypted so I can't see what the values look like for the month to month never expired unless canceled looks like.

Either way, it does look as though the new require info would have to be tied into the function or add it in to the select like the _xclick-subscription.

Either way, how to set it up will be the last thing I worry about since the main thing is getting the code configured right to set up a subscription should the user choose yes in the select.

Old Pedant
11-13-2010, 12:12 AM
For starters, stop using that PHP function that was given to you by that donation tracker org. You can still use them, just don't use their function. It's not doing anything but setting up the <form>'s HTML for you and ensuring that their tracker code gets the notifications.

Just copy/paste the HTML you currently see on the page (clock on the VIEW menu, click on PAGE SOURCE, find the <form>).

And then start altering it to add in the other fields needed.

MoreBloodWine
11-13-2010, 12:38 AM
For starters, stop using that PHP function that was given to you by that donation tracker org. You can still use them, just don't use their function. It's not doing anything but setting up the <form>'s HTML for you and ensuring that their tracker code gets the notifications.

Just copy/paste the HTML you currently see on the page (clock on the VIEW menu, click on PAGE SOURCE, find the <form>).

And then start altering it to add in the other fields needed.

The thing is allowing the required (extra) subscription fields to only be run when the _xclick-subscription is used. Assuming it wouldnt be auto bypassed during a normal donation. In any case, still trying to put something together but as far as the "source" goes, it seems that function is just being turned in to hidden inputs.


<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="donations@myu2sig.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Donation for myu2sig.com !">
<input type="hidden" name="item_number" value="November 2010">
<input type="hidden" name="notify_url" value="http://www.myu2sig.com/stellardonations/ipn.php">
<input type="hidden" name="return" value="http://www.myu2sig.com">
<input type="hidden" name="cn" value="Enter Name to Show:">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="StellarWebSolutions.DonationTracker">

That's also why I initially asked about making an if statement based on the selected value to control individual functions.

Old Pedant
11-13-2010, 12:52 AM
Yes? That's exactly what I saw and why I said what I did.

So add the needed fields for a subscription but still leave it as _xclick and see if PayPal is happy or barfs on your feet.

Then change it to _xclick-subscription and see if PayPal is happy.

You don't need to do this on your live page, of course.

And if you don't want to annoy myu2sig.com, just temporarily omit the notify_url field.

As you said, it's all a sandbox, so what harm can it do to try it?

MoreBloodWine
11-13-2010, 01:06 AM
As you said, it's all a sandbox, so what harm can it do to try it?
None and good points about barfing lol... In any case, my shows are on so I'm gonna take a breather from this and when they're over come back and see if by some stroke of luck I can figure out these damned time variables which is whats really holding me back.

Ideally, and again just to restate... the time frame should be to run month to month with no expiration. Anyway, thx again for all the superb help !

Old Pedant
11-13-2010, 01:35 AM
Hmmm....Have you read this page:
https://www.x.com/docs/DOC-1363

A "subscription" from PayPal's perspective means that you charge the person ONE fee for a a subscription that lasts N days/weeks/months/years.

It does *NOT* mean that PayPal will bill the person each month!!!

What YOU are talking about is what PayPal calls "recurring" payments.

On top of that, did you notice that you need a business account to do subscriptions? Do you have one?

And look especially at the email that "subscribers" automatically get from PayPal. On that page I linked to it is here: "Figure 8. Subscribers Receive Subscription Authorization Notices by Email"

So you *can* do this. But it's not quite what PayPal had in mind and it might feel a bit strange to your clients. But up to you.

MoreBloodWine
11-13-2010, 04:10 AM
Ok, so I worked everything out with the function to get it to work with subs and donations. It seems that PayPal plays nicely when you do subs and ignores the other data or something and displays properly when you choose Yes for a sub.

See below...


function printDonationButton($item_number,$comments=0){
global $currency_code;
global $site_cert_id, $site_sandbox_cert_id;
global $business, $use_encryption;
global $global_anonymous, $notify_url, $return, $test_ipn;

$hash = array(
'cmd' => '_xclick',
'business' => $business,
'cert_id' => $site_cert_id,
'currency_code' => $currency_code,
'item_name' => 'Donation for eojmarket.com !',
'item_number' => $item_number,
'notify_url' => $notify_url,
'return' => $return,
'a3' => '1.00',
'p3' => '1',
't3' => 'M',
'src' => '1',
//'lc' => 'US',
);

In any case, I have one last hurdle to jump and I should be golden.

a3 is the subscription price which is to be hard coded but I would like to allow my users to define said price just like they can with the below input so I ask.Can you think of anything off the top of your head that would replace the a3 figure with the amount noted in the following input ?

<input type="text" name="amount" value="0.00" maxlength="25" style="color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 46%;">

jameslasner
11-13-2010, 07:03 AM
The tracker code was part of something I paid for and modified as needed so I can't post full files but this is everything you should need to figure out whats going on but like I said ideally what should be happening is that when a user selects Yes the image to submit the form should change to Subscribe and if they change it back to No it should change back to a donate button.

MoreBloodWine
11-13-2010, 07:44 AM
The tracker code was part of something I paid for and modified as needed so I can't post full files but this is everything you should need to figure out whats going on but like I said ideally what should be happening is that when a user selects Yes the image to submit the form should change to Subscribe and if they change it back to No it should change back to a donate button.
???

There a point in copying something I previously said ?

Old Pedant
11-13-2010, 10:55 PM
I think "jameslasner" is trying to post an advertising message that's being rejected. Instead, the only part of his post that appears is the copy he made of some prior post. Probably doesn't speak English, so hopes that copying a prior post will look like a relevant comment. He's done this same thing in 4 threads now. Each time just copying a prior post. I've reported him/her/it.

MoreBloodWine
11-13-2010, 11:06 PM
I think "jameslasner" is trying to post an advertising message that's being rejected. Instead, the only part of his post that appears is the copy he made of some prior post. Probably doesn't speak English, so hopes that copying a prior post will look like a relevant comment. He's done this same thing in 4 threads now. Each time just copying a prior post. I've reported him/her/it.

Cool, I figured troll or spam... in any case, you got any ideas on my last hurdle from a previous reply of mien ?


Ok, so I worked everything out with the function to get it to work with subs and donations. It seems that PayPal plays nicely when you do subs and ignores the other data or something and displays properly when you choose Yes for a sub.

See below...


function printDonationButton($item_number,$comments=0){
global $currency_code;
global $site_cert_id, $site_sandbox_cert_id;
global $business, $use_encryption;
global $global_anonymous, $notify_url, $return, $test_ipn;

$hash = array(
'cmd' => '_xclick',
'business' => $business,
'cert_id' => $site_cert_id,
'currency_code' => $currency_code,
'item_name' => 'Donation for eojmarket.com !',
'item_number' => $item_number,
'notify_url' => $notify_url,
'return' => $return,
'a3' => '1.00',
'p3' => '1',
't3' => 'M',
'src' => '1',
//'lc' => 'US',
);

In any case, I have one last hurdle to jump and I should be golden.

a3 is the subscription price which is to be hard coded but I would like to allow my users to define said price just like they can with the below input so I ask.Can you think of anything off the top of your head that would replace the a3 figure with the amount noted in the following input ?

<input type="text" name="amount" value="0.00" maxlength="25" style="color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 46%;">

Old Pedant
11-13-2010, 11:58 PM
I told you what I think is best scheme: Two separate <form>s. It's just getting too complex like this.

You can probably make it work, but man...what a pain.

MoreBloodWine
11-14-2010, 12:03 AM
I told you what I think is best scheme: Two separate <form>s. It's just getting too complex like this.

You can probably make it work, but man...what a pain.

Well, aside from the complexity of it all it plays really well together in it's current format and nothing appears to interfere with this or that. So grant it trying to jump this last hurdle might be a bit of a PIA I don't see why something should be broken up to "jump" this last hurdle. Now that's not to say I eventually wont it this last hurdle can't be jumped but as it stands I don't see it really being needed, assuming a "patch" can be found to get this last thing done.

Don't get me wrong I totally see and get what your saying but really the nly issue that could come from this in it's current format would be a user trying to use the tracker with JS turned off but I already have a fix in the works for that that disables the submit button.

Old Pedant
11-14-2010, 12:35 AM
Okay, okay...

SO just do this:


<form .... onsubmit="this.a3.value=this.amount.value;return true;">

That is, whatever the user types into the amount text field simply gets copied to the hidden a3 field.

I see you are it up as a 1 month subscription with recurring billing. So where do you specify how long the recurrence lasts? I think if you specify src as 1 you have to also supply the srt value? Not sure. And read the docs: For subscription, you are *required* to include the no_note=1.

MoreBloodWine
11-14-2010, 12:50 AM
Okay, okay...

SO just do this:


<form .... onsubmit="this.a3.value=this.amount.value;return true;">

That is, whatever the user types into the amount text field simply gets copied to the hidden a3 field.

I see you are it up as a 1 month subscription with recurring billing. So where do you specify how long the recurrence lasts? I think if you specify src as 1 you have to also supply the srt value? Not sure. And read the docs: For subscription, you are *required* to include the no_note=1.

The only option I'm required ot have as you pointed out is the no_note which I didn't add but will. As for the other stuff, everything I removed was optional. As for something saying what the duration is. If you put in dump info and hit the button just to get to the PayPal page you'll see it says something like $x each month. Grant it it doesn't say if and when it expires but that's stuff I can easily add. The main thing is just tweaking it all to work.

In any case, you have been a god send ;-)

I know I may seem stubborn but to rewrite all this would just mean more work in the long run compared to whats already been done.

Either way, thx !

Edit: Since I already have return defined in onsubmit, how would you work that in to my existing on submit ?

onSubmit="return confirmation()"

Old Pedant
11-14-2010, 01:07 AM
<form .... onsubmit="this.a3.value=this.amount.value;return confirmatiion();">

MoreBloodWine
11-14-2010, 01:33 AM
<form .... onsubmit="this.a3.value=this.amount.value;return confirmatiion();">

Ty for that, and Ty for putting up with me !

I do have one other question but I'll make a seperate thread for that as it doesn't really have anything to do with this. I mean it sort of does but anyway, I'll see if I can work it out on my own first ;-)

Edit: Can you actually test one thing for me, can you see if my confirmation comes up for you on form submit because is use to for me and it's not now and I don;t know if it's just soemthing with my browser or if I goofed the code on an edit, Thx.

Old Pedant
11-14-2010, 02:30 AM
Ever heard of DEBUGGING????

Use Firefox. Install the Firebug debugger.

Though even MSIE will show you the error if you turn on its debugging.



onSubmit="this.a3.value=this.amount.value; return confirmatiion();">

Old Pedant
11-14-2010, 02:31 AM
Teach you to trust *MY* typing.

MoreBloodWine
11-14-2010, 02:36 AM
Ever heard of DEBUGGING????

Use Firefox. Install the Firebug debugger.

Though even MSIE will show you the error if you turn on its debugging.



onSubmit="this.a3.value=this.amount.value; return confirmatiion();">


Ty for that and yes I have heard of it, it also would sound as if I have become an irritant so for that I'm sorry and I think I will just leave this post as is and should I have any more issues I may seek other help so not to irritate you any further.

Again though, you do have my thanks for everything given !

Old Pedant
11-14-2010, 04:03 AM
It doesn't take me long to answer questions like this. I just bring your page up in Firefox and WHAM, there's the error.

My point is, if you would do that yourself, you would also get instant answers. Instead of having to wait around for me.

If you haven't installed Firebug into Firefox, you really are doing yourself a huge disservice. Wasting tons of your own time, honest.

I hope you notice that I made fun of myself in post #42: It was my typo, after all. I can't well blame you for that. Only saying you could have found the problem much faster using Firebug.

MoreBloodWine
11-14-2010, 04:32 AM
It doesn't take me long to answer questions like this. I just bring your page up in Firefox and WHAM, there's the error.

My point is, if you would do that yourself, you would also get instant answers. Instead of having to wait around for me.

If you haven't installed Firebug into Firefox, you really are doing yourself a huge disservice. Wasting tons of your own time, honest.

I hope you notice that I made fun of myself in post #42: It was my typo, after all. I can't well blame you for that. Only saying you could have found the problem much faster using Firebug.
I do have FB and don't really use it to often because I don't quite much get it but I guess I should read up on it. In any case, I did see #42 after I made my one reply. In either case, I really do appreciate all the help you gave me ;-)

Honestly this is probably the best site I've ever used for coding help. I use some others like Daniweb or whatever it is and grant it one hsould never expect answers to quickly but they seem to be slow compared ot here. In either case, I'm gonna mark this as solved because as fa as I can tell everything looks good.

All I gotta do is wait til tomorrow and see what happens with a test subscription of a daily donation. Curious to see if somehow the IPN data is saved at PayPal as part of the sub so tomorrows auto payment shows up on the tracker.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum