Jump to content

Radio button changes style...


Recommended Posts

I have tried so many different approaches. This is what I currently have. I know it's not pretty but my first goal is to get it to work, then figure out how to make it more elegant. I have a form where the required elements are outlined in red. Then I have a radio button input for contact preference with the choices Email or Phone. I want the input for these respective elements to be outlined in red based on the radio button selection. But if they change their mind, the red box has to go back to not being red anymore... Here is what I have so far...

<script type="text/javascript"> function highlight(a,{	thing1 = document.getElementById("a");	thing2 = document.getElementById("b");	thing1.style.border="solid 1px #EE0000";	thing2.style.border="#7F9DB9";} </script><form name="FelixContact" enctype="multipart/form-data" action="process.php" method="post"><table><tr><td>Prefered contact method</td><td><table>	<tr><td>	<input type=radio name="ContactBy" value="Email" onclick="highlight(EmailAddress,PhoneNumber)">Email<br>	<input type=radio name="ContactBy" value="Phone" onclick="highlight(PhoneNumber,EmailAddress)">Phone<br>    </td></tr></table></td></tr><tr><td>Email Address</td><td><table id="EmailAddress" border="0"><tr><td>	<input type=text name="EmailAddress"></td></tr></table></td></tr><tr><td>Phone Number</td><td><table id="PhoneNumber">	<input type=text name="PhoneNumber"></td></tr></table></td></tr>

I also tried onchange instead of onclick and it didn't work either :facepalm:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...