aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes How to reference a variable of jsp in the script function? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "How to reference a variable of jsp in the script function?" Watch "How to reference a variable of jsp in the script function?" New topic
Author

How to reference a variable of jsp in the script function?

qingwu wang
Ranch Hand

Joined: Feb 19, 2003
Posts: 147
Hello everybody!

text1 is a text component in the jsp page,I want to get text value and put it into request string.the *encodeURL*is a function in the jsp page,but I cann't get text1 value in the script.what should I do?


Thanks...qingwu<br />When I open my eyes,I see your pretty face.
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
You've got to keep in mind what happens where with serverside JSP and clientside Javascript.
"<%=encodeURL("/pdajsp/sub.jsp", request, response)%>" is JSP and handled on the server.
The result of the method encodeURL and all other executed JSP is written as HTML to the page and send send to the client then.
If you look at the html source in the browser you can see that the form's action-attribute contains a URL.
"document.form1.text1.value" is the value of a textfield, wich assumably is changed by the user... on the client side (where else?).
If you want to concatinate the textfield's value to this URL before submitting the form, you can use something like this:

hth cb
qingwu wang
Ranch Hand

Joined: Feb 19, 2003
Posts: 147
Thanx a lot
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to reference a variable of jsp in the script function?
 
Similar Threads
Regarding document object in javascript
How I can add numbers in ASP with little logic
Page reloading problem
Double Byte Character "%" validation needed in Javascript
Need Javascript code to populate a field with one value from a list of values