Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 1st, 2010, 10:12 AM
Authorized User
Points: 373, Level: 6
Points: 373, Level: 6 Points: 373, Level: 6 Points: 373, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2004
Location: , , .
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
Default Write variable from JavaScript to ASP page

Good morning.

I'm building an expense report in ASP. People will enter their expenses on a form (they can enter up to 20 expenses) and at the bottom of the form a running total (in US dollars) will appear. When the user exits the field (onblur), javascript is called which adds up the numbers and stores the total in a variable.

I need to display this JavaScript variable on my form but I can't figure out how to do this: I can't figure out how to display the JavaScript variable inside my asp code.

I WAS able to use an input text field and use that for the running USD total. I would simply set the value of the input text field to the javaScript totals field and all was well however, I don't like the way the input field looks: users may think they can type inside it.

Please help: I just want to display the total as text only!

Thank you!

Sal
  #2 (permalink)  
Old November 1st, 2010, 03:25 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Code:
Total is $<span id="total" style="...your choices...">0.00</span>

and then 

document.getElementById("total").innerHTML = total.toFixed(2);
Another choice: Go ahead and use an <input> field. But do this to it:
Code:
<input name="total" readonly style="border: none; background-color: #eeeeee;" />
That is, style the input so it no longer looks like an input field. And make it readonly, so the user *can't* type in it.

If this doesn't help, show your JS code.
  #3 (permalink)  
Old November 2nd, 2010, 01:40 PM
Authorized User
Points: 373, Level: 6
Points: 373, Level: 6 Points: 373, Level: 6 Points: 373, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2004
Location: , , .
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you!

getElementById is working well.

sal


Similar Threads
Thread Thread Starter Forum Replies Last Post
storing Javascript variable to ASP variable rupen Classic ASP Basics 5 April 10th, 2007 07:06 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 07:35 AM
ASP variable inside my JavaScript crmpicco Javascript How-To 1 June 4th, 2005 12:17 AM
set a asp variable with a value in Javascript crmpicco Javascript How-To 6 March 11th, 2005 11:07 AM
using asp to write javascript vivalet Classic ASP Basics 3 November 6th, 2003 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.