0

Hi,

I have a problem with capturing a number that is generated with a javascript.

Let me explain. Its a shopping cart. when people choose to buy a package, there is a total that is visible. This total changes as they choose more or less packages. The total is handled with a javascript that updates the total as people click on items.

My question is how do i capture that total into a variable and bring it over into a checkout page to be passed to the banking page?

Any help will be highly appreciated.

Thanks

3
Contributors
13
Replies
14
Views
7 Years
Discussion Span
Last Post by saiprem
0

post your code here.

<div id="showqtyint" style="float:left" class="q-sm txt-gray txt-med">0.00</div>

This above value changes as people choose a package. is there a way to capture the amount?

Thanks

0

Hi,

I have a problem with capturing a number that is generated with a javascript.

Let me explain. Its a shopping cart. when people choose to buy a package, there is a total that is visible. This total changes as they choose more or less packages. The total is handled with a javascript that updates the total as people click on items.

My question is how do i capture that total into a variable and bring it over into a checkout page to be passed to the banking page?

Any help will be highly appreciated.

Thanks

There are 2 ways...

1. Add a hidden variable to your form, When total is updating, Just assign the same total value to your hidden variable, When your form is submitted call that hidden variable name, you will get your total value there....

2. When total is updating, make an ajax call and add the total for that particular userid

Hope it helps you to do...:)

0

Hi there, yeah i already tried that but if i view the source of the page the innitial value of 0.00 is there, while the updated value 24.99 is nowhere to be found on the page. It looks like the value is being kept in the session but not written in the html.

May i post a link to the page here for you to see?

0

Hi there, yeah i already tried that but if i view the source of the page the innitial value of 0.00 is there, while the updated value 24.99 is nowhere to be found on the page. It looks like the value is being kept in the session but not written in the html.

May i post a link to the page here for you to see?

If you view the source in IE, It will shows like that only.., try to see the same in firefox, you will know...

As you said you are updating the innerHTMl of div, after updating the div with that value, you just assign the same value to the hidden variable in the form, if you post the form, the hidden variable will carry the value what ever there in the div.

You need to add a hidden variable in the form as shown in the below...
<input type='hidden' name='updated_price' id='updated_price'>

after updating the value of div in the js code

add the below line
document.getElementById('updated_price').value = thevalue_which_u_have_caluculated_to_update_div;

If still you can't find what needs to do, jus post your code.... or post url in the forum...

0

take hidden field and store total amount. when click package write there onchange event. in that function assign hidden variable to div
do like this

document.getElementById('showqtyint').innerHTML=document.getElementById('hiddenvariable id').value;

Edited by rajabhaskar525: n/a

0

take hidden field and store total amount. when click package write there onchange event. in that function assign hidden variable to div
do like this
document.getElementById('showqtyint').innerHTML=document.getElementById('showqtyint').value;

Hi Rajabhaskar, I didn't understand your code, can you please make bit more clear....about it.

0

see this
link

in this, if you update the quantity and click update button. the total amount will update .

Edited by rajabhaskar525: n/a

0

see this
link

in this, if you update the quantity and click update button. the total amount will update .

Oh..The site really superb, but the problem of "Addweb" is not that, he is unable to send the result to next page....

He doesn't have chance to access the last page data...

0

i think your problem is if click interanational tab and select quantity the price will display below. these total price doesnot carry to southafrica tab.

may i see the total page code. link it as attachment.

Edited by rajabhaskar525: n/a

0

http://www.ama-zingpack.com/purchase.php

If you click on the values you can see the total updates itself. But in the source code the updated value is nowhere to be found.

The div tag stays 0.00 - so im stuck here

Before/After this in your page

<select onchange="updatepriceint();" name="singleqtyint" id="singleqtyint" class="select-btn">

Add a hidden variable
<input type='hidden' name='updated_price' id='updated_price'>

in your javascript function updatepriceint()

Before/After assign the updated_price value like as shown in the page....

you have this
document.getElementById('showqtyint').innerHTML='$ '+totalint; 

Add this..
document.getElementById('updated_price').value = '$ '+totalint;

In the next page, retrieve the value of updated_price as

$_POST['updated_price']

Hope it helps you to fix your issue....

Edited by saiprem: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.