faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 32 people (72%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

Can I make an image visible or invisible based on value of a text box?

Apr 6th, 2008 19:38
ha mo, Colin Fraser, Kathy,


Yes you can. The problem is how can you evaluate what is in the text box. 
Try using a button : 
<script>
function evalTextbox(){
   if (document.myForm.myText.value=="oh my word lordy") {
       /*do an image swap right here.. swapping an image for a    
         transparent image, or the other way round */
       document.images[myImage].src = "myRealimage.gif";
  }
</script>
In the page use : 
<IMG SRC="myTransparentImage.gif" name="myimage">
<form name="myForm" onSubmit="return evalTextbox()">
<input type="text" name="myText">
<input type="submit">
</form>
Good luck
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com