Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

using variable to set textfield

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have question, sounds simple, but I'm very new to JSP

Code Snipet:

<logic:equal name="myDetailsActionForm" property="myDetails.listBoxPopulated" scope="request" value="true"> <html:text name="myDetailsActionForm" maxlength="3" size="3" property="myDetails.textBox" styleId="TxBox" disabled="true" /></logic:equal><logic:notEqual name="myDetailsActionForm" property="myDetails.listBoxPopulated" scope="request" value="true"> <html:text name="myDetailsActionForm" maxlength="3" size="3" property="myDetails.textBox" styleId="TxBox" disabled="false" /></logic:notEqual>


Using this same code, if I had another text box, is there a way that I can populate this text box, using the value of the fist one...

What I want to do is when the code evaulates to the notEqual, it will display the tesxt field, but it will be readonly and it will have the string value that was entered into another textbox.

ie, when I do this:

<html:text name="myDetailsActionForm" maxlength="3" size="3" property="myDetails.textBox2" styleId="TxBox2" disabled="false" value="myDetails.textBox2.value"/>

It seems that any combination I've tried with the value="myDetails.TxBox.value" will always put the string "myDetails.TxBox.value" in the text box, what I want is the value in the textbox, (the string that the user entered in)

I have tried all sorts of combiniation, but I always get the string of what ever is inside the " " value="whatEverIsHere"

Am I going complete the wrong way about this...?
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by John Brown:
if I had another text box, is there a way that I can populate this text box, using the value of the fist one...


How about writing out a JavaScript call that will copy the value?
 
John Brown
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried that a few times, different ways,
basically I end up with this in the java script:

(my java script is in a seperate details.js file)



(Do I need the <% %> brackets? I have tried it both ways,
and do I use var or String? also tried this both ways,)



and my JSP code then becomes this:



but the error I always seem to get is:

cannot resolve symbol
symbol : variable myString
location: class jsp_servlet.__myDetails
out.print(String.valueOf(myString)); //
/myDetails.jsp; Line: 122]
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you think the jsp compiler will identify the variable declared in your javascript???

In your js file :

var myString = document.findElementByID("TxBox1").value;
document.findElementByID("TxBox2").value = myString;

is this what you are looking for??
 
Hang a left on main. Then read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic