views:

44

answers:

1

As the title suggests, I have a span that is automatically generated by SimpleCart (Javascript Cart) - I want to use that span with a different checkout gateway then they support. Therefore, I need to take some of their tags and "echo" them into PHP variables.

For example:

<input type="hidden" name="fltAmount" value="###">

<span class="simpleCart_finalTotal">

The SPAN needs to be able to be passed into the INPUT so I can send it off to Paypoint.net

+2  A: 

Your code should look something like this:

<input type="hidden" name="fltAmount" value="" id="fltAmount">
<span class="simpleCart_finalTotal" id="finalTotal">

And in the form, you will call a function (onsubmit) that looks like:

<form onSubmit="calledOnSubmit(event)" ... > ... </form>

An the function:

function calledOnSubmit(event) {
  var inputAmount = document.getElementById('fltAmount');
  var spanTag = document.getElementById('finalTotal');

  inputAmount.value = spanTag.innerHTML

}
Garis Suero
Testing this out now. Thanks for the response!
gamerzfuse
You can always do some validations to guarantee integrity...
Garis Suero
Your code should not look like its from the 90's. Don't use JavaScript directly in your HTML. Events should be attached unobtrusively, and behavior separated from structure.
Justin Johnson