This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Unhide the text field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Unhide the text field" Watch "Unhide the text field" New topic
Author

Unhide the text field

Vandiyadevan senthan
Ranch Hand

Joined: Nov 11, 2003
Posts: 37
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jul 31, 2003
Posts: 263
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.


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Tom the person just wants to show a hidden form element on the page....
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
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

Joined: Feb 20, 2001
Posts: 3695

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

Joined: Jul 31, 2003
Posts: 263
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unhide the text field
 
Similar Threads
how to make a link readonly?
enabling and disabling text fields and buttons
alternate row colors in jtable when cells are panels
How to set Value from 1 frame to another ?
Problem with colors of button.