Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unhide the text field

 
Vandiyadevan senthan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I have a textfield which is of hidden type and a button in a web page.whenever i click the button it has to show the text field and its default value in that .
can anybody give a solution for this.
Thanx in advance.
Regards,
Vandiyadevan
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not want to use a hidden field.
You need to use a regular text box with style="visibility:hidden"
when you want to show it
document.getElementById("ElementName").visibility="visible";
Eric
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't really change a field type. If you just need to display text in a field when a button is pressed, you can use the onClick event to place the text into the text field.

In the code, you'll notice I had to replace onClick with onKlick to post it to the list. Change it back to onClick to run it.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom the person just wants to show a hidden form element on the page....
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
Tom the person just wants to show a hidden form element on the page....

Eric, it's six of one or half a dozen of the other. Use JavaScript to change the visibility, or use JavaScript to add the value to a previously empty text box. It's exactly the same amount of code give or take a few characters.

--OR--

[ November 18, 2003: Message edited by: Tom Blough ]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom: That's not the same thing at all.

If someone used your method, then when the form is submitted, any 'hidden' values are sent as empty string, when it in fact they should contain some value. We want to hide the value from a user, not null it.

The requirement of the original poster is fuzzy, and its unclear if a value should be submitted for 'hidden' fields or not. But I thought i'd point out that Erics method and your method do NOT produce the same results server-side.
[ November 19, 2003: Message edited by: Mike Curwen ]
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right Mike. I didn't think about if he needed the value in the hidden element. I assumed it was something like an online practice test where the button was "check you answer".
That's what I get for assuming
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic