aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes 2 Quick simple JavaScript Qu's. Plz Help Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "2 Quick simple JavaScript Qu Watch "2 Quick simple JavaScript Qu New topic
Author

2 Quick simple JavaScript Qu's. Plz Help

Daniel Iszatt
Greenhorn

Joined: Feb 08, 2003
Posts: 4
I have a JSP page that has a JSP code fragment that fills up a string variable.
I also have some functions in JavaScript that need to use the string varaible as the input.
Can I use this a string variable from JSP in JavaScript? If so How?
Qu 2) The result from my JavaScript function will also be a String. I want to send that string as a hidden field in a form. How do I access JavaScript variables in HTML to be posted in a form?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15362
    
    6
document.FormName.HiddenElementName=strVar;
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56529
    
  14

You can't directly access the Java string in your page since the Java is executing on the server to format the page which is sent to the client.
What you can do, is to create JavaScript strings from the Java strings that will be sent to the client as part of the page.
For example:

hth,
bear
[ February 08, 2003: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Daniel Iszatt
Greenhorn

Joined: Feb 08, 2003
Posts: 4
Thanks. That will help me sort things out. I'll try playing about with it 2morrow at work.
Thanks again.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: 2 Quick simple JavaScript Qu's. Plz Help
 
Similar Threads
How to refer a java variable in javascript code.
Use a JSP variable in JavaScript? Plz Help
multiple actions for a single form without using javascript
Calling a jsp page from javascript
How do you set a javascript variable from jsp?