Log in

View Full Version : Looking for a form effect



jc_gmk
01-22-2008, 12:31 PM
Does anyone know if this is possible:

I have a simple form with a select box that has three drop down options.

e.g.

<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>

This is what i'm trying to do:
When someone selects option "two", another form field is then revealed.
Would be nice if this could be done with some kind of transition effect - but not essential.
Option "one" and "three" should have no effect.

Presumabley I would need to do this with Javascript as the field would need to be revealed before the form was submitted.

TimFA
01-22-2008, 02:08 PM
Here you go, it won't work in IE but thats IE's fault...for some reason onSelect and onFocus don't work on that field. Hmmmm, I never noticed. Anyways this code might work in IE 7 I'm not sure, I know it doesn't work in IE 6.



<html>
<head>
<script type="text/javascript">
function Num2() {
document.getElementById("DIV").style.display='inline';
}
</script>
</head>
<body>
<select>
<option>1</option>
<option onClick="Num2();">2</option>
<option>3</option>
</select>
<br>
<div id="DIV" style="background:#000000;display:none;color:#ffffff;">
This is the test.
</div>
</body>
</html>


Best I could do, sorry.

Tim

EDIT: Just in case this wasn't clear, the extra form field would go in the DIV, or you could make a field and ID it. But make sure to change this reference:



getElementById("DIV")