| 1. |
Solve : Form field prompts? |
|
Answer» Hi, I have several text fields in a (frontPage) form. I would like to have words (in light gray) in the text boxes to prompt the USER as to the information needed. As soon as the user starts to type in the text box, the 'prompt' would disappear and only the users text would be submitted. I see this used all the time but don't know how it is done. Is it HTML or java or what? JavaScript. MODEL:Need more of a script so... Thanks, Ed Quote for each time I use this, changing 'MAKE' to each Id? I want to use this for 8 fields!Sorry, I didn't realise this was for more than one. You can use this instead: Code: [Select]<script type="text/javascript"> function changeColor(id) { var input = getElementById(id); input.style.Color = "#000"; input.style.fontStyle = "normal"; } </script> And the input field: Code: [Select]<input type="text" style="color:#CCC;font-style:italic;" value="Example Dodge" onfocus="changeColor(this.id); this.value='';" name="MAKE" id="MAKE" size="20" /> All you have to do is add id="MAKE" to every input field...as well as the onfocus function. Quote OK, Now I know I am becomming a pain.Don't worry about it. OK. I'm learning. See, you can teach an old dog new tricks! This part is still a problem: 2) The font is changing correctly but when the user puts data in the field the prompt does not disappear. Stays in background as user types input. Thanks. Ed Quote 2) The font is changing correctly but when the user puts data in the field the prompt does not disappear. Stays in background as user types input.Did you add onfocus="changeColor(this.id); this.value='';" to the field?Here is what i have: I am ALSO getting a script error on the above line. Maybe the line before is messing it up with the validation? EdHmmm, okay try this: Code: [Select]<input type="text" style="color:#808080;font-style:italic; margin-left:Dodge" value="Example Dodge" onfocus="changeColor(this.id);" onclick="this.value=";" name="MAKE" id="MAKE" size="20" maxlength="20" />Hi again, While I was taking your time trying to figure my error I reviewed everything and found the problem. I had used a " instead of ' ' , as in this.value=";" should have been this.value='';" Now it works and no script error. Thank You so very much for your patience with me. The related issue I'm having is with the confirmation page. My ISP PROVIDES one CGI script which they control. It gives a confirmation page to the customer. This page is called thankyou.html and it is in my control. The script also sends an e-mail. The e-mail SHOWS the field id and the user input. I can not get the user input to show up on the confirmation page. In the design of the page it shows the field confirmation as a webbot so that part appears to be correct. When it displays after input, it is blank where the user input should be. Is there a way to get this field data to the e-mail and the confirmation page? Thanks, Ed Have you got a link to the page?Yes, www.rubins.com/testing.html |
|