473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Best way to update a value dynamically

I may be posting to completely the wrong newsgroup, but I need to ask.

Basically I have created a shop cart that displays the current running total
in the header of my site so that it appears at the top of every page.

This value is updated when the customer adds to the basket, but the problem
is that this value is displayed before the basket routine calcs what the
running total is which makes it look a little silly as this value is always
out from the basket total when they do any changes.

I want to keep it at the top rather than put it at the bottom where I know
it will work, but I will lose the effect I am trying to create.

So what I'm basically asking is, do you know of a routine that can
dynamically go and change the header value once I have the basket total?

I was going to use .InnerText by putting the header value in a <SPAN
ID=xx>thevalue</SPAN>, but I have a feeling that this isn't as
cross-platform compatible as it should be. Am I right?

Any better ideas?

Rgds

Robbie


Jul 20 '05 #1
1 1266
DU
Astra wrote:
I may be posting to completely the wrong newsgroup, but I need to ask.

Basically I have created a shop cart that displays the current running total
in the header of my site so that it appears at the top of every page.

This value is updated when the customer adds to the basket, but the problem
is that this value is displayed before the basket routine calcs what the
running total is which makes it look a little silly as this value is always
out from the basket total when they do any changes.

I want to keep it at the top rather than put it at the bottom where I know
it will work, but I will lose the effect I am trying to create.

So what I'm basically asking is, do you know of a routine that can
dynamically go and change the header value once I have the basket total?

I was going to use .InnerText by putting the header value in a <SPAN
ID=xx>thevalue</SPAN>, but I have a feeling that this isn't as
cross-platform compatible as it should be. Am I right?

Any better ideas?

Rgds

Robbie


I think you should just use an <input type="text" name="TotalShopCart"
value=""> for your shopcart total value which value can be dynamically
updated thanks to an onchange event handler on item elements. You can
still use a <span> but that's not the best/ideal element to render
calculated values.

Assuming
<span id="idShopCartTotal">&nbsp;</span>
then

function UpdateShopCartTotal()
{
var Total;
(...) some loop which will cumulate the elements' values in the shop
cart (...)
if(document.getElementById &&
document.getElementById("idShopCartTotal").childNo des[0] &&
document.getElementById("idShopCartTotal").childNo des[0].nodeType == 3)
{
document.getElementById("idShopCartTotal").childNo des[0].nodeValue = Total;
};
}

DU
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Craig Keightley | last post by:
I have the following form in which i need to updateitems. The problem is that i do not know how many elements will be in the form (generated dynamically) eg <input type = "hidden" name ="id1"...
7
by: jason | last post by:
Is there a way - possibly a disconnected rs? - to update the contents of an existing pulldown on a page without having to re-submit the page for the user to see the pulldown populated with an...
9
by: Art | last post by:
Can I update Application("SomeVariableName") on server A in response to user's action on server B? There is no problem in updating the same variable on server B, of course, but we would like both...
5
by: Michel | last post by:
Hi there, What is the best way to serialize unknown data? I have a class that contains a list of parameter objects. The parameter has a value which can be a simple value of a complex class,...
6
by: heybrakywacky | last post by:
After hours of pulling my hair out on this one, I've finally realized that the problem I'm having in my code is due to behavior that is not at all expected. Using ASP.NET 1.1.4322.2032, I'm...
1
by: sufferthefools | last post by:
i have been taught always to use the data module and place all the necesary components on it and refer to it when i need something. but is this the best programming practise?? i get a lot of...
13
by: Martin Z | last post by:
I'm making a CRUD screen for an Oracle database... but problem is that the primary key in that table is populated via an autonumber, which in Oracle is done just with triggers and sequences. ...
5
by: sean.gilbertson | last post by:
Hi, I'm sort of new to ASP.NET 2.0 and ASP.NET in general. I have some data that I would like to display in a tabular format, but I'm going to be generating the columns dynamically, and I would...
10
by: phopman | last post by:
Hi there! Thanks for all the help so far. When my boss said I should be up to date as soon as possible, he meant last week. So I got a good rollicking when I came to work. Nice way to start my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.