473,597 Members | 2,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTML dynamic calculation

2 New Member
I have following code in HTML file:

<p><strong>Quan tity:</strong><br/>
<input type="text" name="Quantity" size="10" maxlength="10">

<p><strong>Unit Price:</strong><br/>
<input type="text" name="Unitprice " size="10" maxlength="10">

<p><strong>Tota lPrice:</strong><br/>
<input type="text" name="Totalpric e" size="10" maxlength="10">

My question is that, I have to show the calculated value in the field "Totalprice " dynamically with the changed value of "Unitprice" as well as "Quantity" in the same page where "Totalprice = Quantity * Unitprice".

can someone help to do this???

Dec 2 '07 #1
2 2069
7,435 Recognized Expert Expert
html/css cannot do this. You need a programming language.
Dec 2 '07 #2
2 New Member
Without the whole code I have no idea what you are trying to do. It looks like you are trying to create a form.If you wanted the broswer to calculate the total before the form is submited you would need to use javascript(clie nt side code). No good at javascript so i'll leave that for someone else.

If you want a user to input the "quantity" and "unit price" and submit it to the server before showing the result (recommended approach), you need to use a server language such as PHP, ASP, Cold Fusion etc.
If you haven't considered using these before be prepared to do a lot of reading.

You would most likely need to pull the Unit price from a database or code it into the page. Not sure why you would want an input field for this.

Anyway back the original question-
PHP example code would something like this.

$quantity = 5;
$unit_price = 10;
$total_price = ($quantity * $unit_price) ;
echo $total_price;

output of the above code would be-

this code by itself is basically useless. If you are serious about creating dynamic pages start learning PHP or ASP
Dec 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Tag | last post by:
Altova StyleVision has good features for generating hyperlinks with both static and dynamic segments. But I don't quite see how to create an anchor in the same document, so I can, for example, jump from a Table of Contents to a section like this -- <A HREF="#section_name">section_name</A> ... <A NAME="section_name"> On the contrary, the Help File forcibly denies that what it calls a
by: yzarc | last post by:
I'm working with a DB design that seems to me to be rather complex. This is a very slimmed down version of what I'm doing, but I believe it is enough to get my question resolved. Here is my layout. These 4 tables are used to generate a questionaire. Survey OrderID
by: Tim.D | last post by:
People, I've ventured into the wonderful world of Stored Procedures. My first experience has been relatively successful however I am stuck on using host variables to specifiy actualy table or column names in a FROM clause. After many hours or reading all manner of manuals I've discovered it appears this is not possible and that in order to so I need to further venture into dynamic SQL. My present procedure is based on all static SQL...
by: Homam | last post by:
So I have a composite paging control that shoulld be positioned on the page like this: PagNav ResultSetDisplay PagNav I know that I can't resuse the PagNav more than once in the form, so I instantiate a couple of instances, PagNavTop and PagNavBottom, and thus I end up with:
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim ld_tot_pet_clean_fee_calc As Double ld_tot_pet_clean_fee_calc = li_net_total_calc * 0.0075 ld_tot_pet_clean_fee = lo_misc_func.FormatMC(ld_tot_pet_clean_fee_calc, "D") Session("tot_pet_clean_fee") = lo_misc_func.FormatMC(ld_tot_pet_clean_fee, "D")...
by: murrayatuptowngallery | last post by:
After a few searches & inquiries here, I have a method of generating an html table populated with results of equations that works and wasn't too far up a learning curve for me, thanks to a helpful respondent/poster here... <script type="text/javascript"> var AAA = new Array(4) AAA = 2*0.1*Math.round(10*Math.log(32)/Math.log(2)) AAA = 2*0.1*Math.round(10*Math.log(16)/Math.log(2))
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. Using Safari,my first iteration the script works fine ( indicating that there are 33 form variables ). When trying another dropdown select value, the
by: victor1981 | last post by:
Hi guys, Its my first post and i hope that you will answer my query. I want to transfer my salesdata report from excel to Access and The issue I am facing is that there are lot of formulaes in my excel file which are used dynamically.for eg.I have this monthly sales data jan feb mar apr 30 40 10 56 So YTD sales for FEB would be sales of jan+sales of feb and so on. In excel you put a formulae in the feb...
by: ive1122 | last post by:
Hi guys, I am looking into create a dynamic survey as posted in Get User Input From Dynamic Controls but with some different environment Below is what i am trying to do: First when the user click the button, it will populate a dynamic table with radio button for the survey questionnaire However, i was unable to get its value (for score calculation) after clicking the submit button Beside i am using an ajax extension (updatePanel) for the...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.