• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Unhide the text field

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
expectation is the root of all heartache - shakespeare. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic