If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Passing span value to PayPal

I have a js script which prints a value to innerText of a span. I am trying to take this value and pass it onto paypal as an amount.

The process goes:

form.php --> process.php --> PayPal

Because i am using a script i found online i cannot go directly to PayPal as the form action is already set to the send.php. Therefore i need to pull the value from span in form.php, into process.php and then into PayPal. I have tried using $_SESSION variables but it didn't work and when i var_dumped the session it showed an array when i was expecting a simple integer.

Well, you have ID's on them, so innerText on the element would be easiest. For example your "words" property... I'd probably make a function for that to do the getElementById and the cross browser innerText thus:

Though I have to ask, why do you have LABEL pointing at SPAN? LABEL is for INPUT, TEXTAREA and SELECT inside a FORM, (preferably with a FIELDSET wrapping said form elements). If you really are going to use LABEL, maybe you should use a <input type="readonly"> since it's far easier/reliable/faster to read .value from an INPUT than innerText from a span.

You STILL have label tags pointing to a span tag - not what they are used for.

Regarding your limited knowledge: Not knowing how this 'link' to a paypal process is going to facilitate whatever you are doing, but does your limited knowledge provide you with the right concerns for security and input validation and protection against potential malfeasance with your paypal connection? If I were you I would NOT be using my current skillset for such advanced (and perhaps tragic?) implementations.

PS - It's not nice to laugh at people who are attempting to help you, while still ignoring what they told you.

And yes i am probably a bit out of my depth but i have found over time that this is the fastest way i learn, but i wouldn't jeopardise someone's website until i understand what i am doing and implement it correctly.

They are global in terms of JavaScript, but couldn't be used on other pages because when you refresh the page globals are erased. To get them to another page you'd have to submit them as formdata, use javascript with AJAX to pass them in a fake form or as URI getData, or store it in a cookie.

Oh, and don't sweat the 'haha' -- it's good to hear you at least have the form and fieldset part right, it's just those SPAN don't make any sense. LABEL are for INPUT, SELECT and TEXTAREA -- and that's IT. You don't use them to point at other tags.

REALLY looking at this, it starts to sound like you should just be using readOnly input and doing normal form submissions, instead of playing with JavaScript, but that's really hard to dial in closer without seeing the full form.

value has to be that value, you can't just say a javascript variable name as a value, all you've done is set value to the STRING "npfinal" and passing that to PP. Markup does NOT have access to JavaScript variables.