• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using variable to set textfield

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic