By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

problem with retrieving value from asp-textbox

100+
P: 103
Hi all,

I am having two textboxes

First textbox is used to enter the price per unit of an item..

Second TextBox is used to enter the number of items..

I have a label which should display the total amount , ie, priceperunit*numberofitems..

The total amount should be displayed whenever the user enter the numberof items...

I have to write the javascript code to find the total..

Please help me...

Regards,
Mathew
Nov 6 '07 #1
Share this Question
Share on Google+
7 Replies


Markus
Expert 5K+
P: 6,050
Hi all,

I am having two textboxes

First textbox is used to enter the price per unit of an item..

Second TextBox is used to enter the number of items..

I have a label which should display the total amount , ie, priceperunit*numberofitems..

The total amount should be displayed whenever the user enter the numberof items...

I have to write the javascript code to find the total..

Please help me...

Regards,
Mathew
Sounds like you want us to write it for you...

Just read some tutorials

=]
Nov 6 '07 #2

gits
Expert Mod 5K+
P: 5,390
hi ...

please show some code you have done so far ... so that we may have a look at your attempt and its particular problems if there are any ...

kind regards
Nov 6 '07 #3

100+
P: 103
Hi,

I have written the Javascript code as given below.

JavaScript
...............
Expand|Select|Wrap|Line Numbers
  1. function calculatesum()
  2. {
  3. noofitems=document.getElementById("ctl00_ContentPlaceHolder1_txtNoofItemsPurchased").value;
  4. priceperunit=document.getElementById("ctl00_ContentPlaceHolder1_lblPricePerUnit").value;
  5. var total=noofitems*priceperunit;
  6. return total;
  7. }

and when i execute the program i met with some error saying that

"The server tag is not well formed."

I am having the textbox property as given below

Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtNoofItemsPurchased" runat="server" Height="15px" Style="left: -14px; position: relative;
  2.         top: -9px"; Width="42px"; OnTextChanged="return calculatesum()"></asp:TextBox>
Please let me know where i went wrong...

regards,

Mathew
Nov 6 '07 #4

gits
Expert Mod 5K+
P: 5,390
changed thread title to better describe the problem ... please always use a good thread title ...
Nov 6 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Where's the code for the label?

Can you post the client-side version of your ASP.NET code?
Nov 7 '07 #6

100+
P: 103
Where's the code for the label?

Can you post the client-side version of your ASP.NET code?
The code of Label is given below...

<asp:Label ID="lblPricePerUnit" runat="server" Height="20px" Style="left: 80px; position: relative;
top: -41px" Width="91px"></asp:Label>
Nov 7 '07 #7

acoder
Expert Mod 15k+
P: 16,027
If you view the source in the browser on the client-side, is the label ID still the same or has it changed to something else?

Whatever the ID is, use that with document.getElementById(labelID).innerHTML to set the label with the total.
Nov 7 '07 #8

Post your reply

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