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

Recommended Answers

All 13 Replies

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

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...:)

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?

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...

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;

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.

see this
link

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

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

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...

i saw your link it is working fine . what is your problem. can you exaplain

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.

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....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.