• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

to print the value from a javascript function

 
divya chamarti
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any body tell me how to tak ethe value from javascript function and print it on html page
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
print which value ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
divya chamarti
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic