PDA

View Full Version : Dynamically displaying some text on selectbox selection


QuackHead
11-01-2002, 09:57 PM
Ok, here's my problem.... I haven't been able to find any answers to anything like this on the forums... here goes....


I have a form. In that form I have a select box, when (specifically) one of the items is selected, I need a red star (or something similar) to show up beside one of my text boxes (Indicating a required field ONLY if a specific value is selected in the select box.)

Has anyone done anything like this before? If so, can you please help me out.

I'm gunna get started on my own, and the only thing I can think of is the InsertAdjacentHTML thing...

Let me know, thanks

~Quack

Roy Sinclair
11-01-2002, 10:06 PM
Why not place a blank image there in the first place and then perform a simple image swap when the field becomes required. That'll be workable on a lot more browsers than using the non-standard insertAdjacentHTML. It should also be simpler. :)

QuackHead
11-01-2002, 10:09 PM
Originally posted by Roy Sinclair
Why not place a blank image there in the first place and then perform a simple image swap when the field becomes required. That'll be workable on a lot more browsers than using the non-standard insertAdjacentHTML. It should also be simpler. :)

Yeah, that'll work, and I think I'll do that until I figure out the other way. Thanks Roy

If anyone does know how to do it text based (my preferred method for this particular site...) please feel free to fill me in ;)

Thanks

~Quack

Simrey
11-02-2002, 09:50 AM
Something like this might do it:


<html><head><title>Testit</title>
<script language="JavaScript">
function showhide(d,tf) {
var str,vh;
if(document.all) str="document.all['"+d+"'].style.visibility=";
else str="document."+d+".visibility=";
tf ? vh="'visible'" : vh="'hidden'";
eval(str+vh);
}
</script></head>
<body>

To display the star mouseover
<a href="#" onMouseOver="showhide('rechoired',true)"
onMouseOut="showhide('rechoired',false)" onClick="return false">here.</a>

<div id="rechoired"
style="position:absolute; left:100px; top:100px; color:#ff0000; visibility:hidden">
*<br>
</div>

</body></html>