aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes to print the value from a javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "to print the value from a javascript function" Watch "to print the value from a javascript function" New topic
Author

to print the value from a javascript function

divya chamarti
Ranch Hand

Joined: Jul 28, 2006
Posts: 56
can any body tell me how to tak ethe value from javascript function and print it on html page
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

print which value ?


[My Blog]
All roads lead to JavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Something like this:



If the page has been completely rendered (i.e., you want to do this at a later point in time, e.g. during an event handler) you'll have to use DOM to set or change text on a page.
[ September 08, 2006: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
divya chamarti
Ranch Hand

Joined: Jul 28, 2006
Posts: 56
no i do not want that the value print in same javascript function
actulayy what i want is :
i have a select button and when user selected one of the option then that option is stored by the onChange event and by that javascript function i am capturing the value selected , and now i want to store this value in a variable and i want to use this value at alter point of time i mean either in the same html page or in the same jsp page
please suggest me how to retrive this value???
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9317
    
109

and now i want to store this value in a variable and i want to use this value at alter point of time i mean either in the same html page or in the same jsp page


Why dont you store the value in the Session, if you want it across jsps?


[My Blog] [JavaRanch Journal]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no such thing as session in JavaScript so I think the last comment is confusing things.

Why don;t you just access the field when you need it and not when there is an onchange?

var sel = document.forms[0].selectName;
var val = sel.options[sel.selectedIndex].value;

If you want to do it onchange than you need to set it to a glable variable. If you need the value on the server side, submit the form.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to print the value from a javascript function
 
Similar Threads
question about jcheckbox
Printer Connection
missing name after . operator ?
returning value from jQuery
Can I get javascript var in html ?