Page 1 of 1

highlight questions in php web form

Posted: Thu Nov 17, 2011 6:36 am
by pmarley2
what's would be the easiest way to highlight a question in a web form a certain color? say i have a standard question with radio buttons:

Code: Select all

    
<form id="form1" name="form1" method="post" action="feedback.php">
      <p class="style13"><strong>Do you play basketball?</strong><br />
        <input name="q1" type="radio" value="yes" />    &nbsp;Yes
        <br />
        <input name="q1" type="radio" value="no" />    &nbsp;No
        <br />
        <input name="q1" type="radio" value="dont_know" />    &nbsp;Don't know
        <input name="submit" type="submit" value="SUBMIT" />
      </p>
    </form>
If the user clicks on any of the radio buttons or the question itself, I want a colored box around the whole question (including answers) to light up so that the question is highlighted. it would also be okay if i could get the question to be highlighted when the mouse hovers over it.

thanks!
~p

Re: highlight questions in php web form

Posted: Thu Nov 17, 2011 7:05 am
by Celauran
Use JavaScript to set the style onclick.

Re: highlight questions in php web form

Posted: Thu Nov 17, 2011 7:14 am
by unexperion
He told me the same thing yesterday :) :)
So, the procedure is to make a style, set the parameters for onclick, onmouseover etc. save it to root, and call to them in every <input ... > section of your code. Something like that...
<link rel="stylesheet" href="style1.css" id="stylesheet">
<script type="text/javascript">

function changeStyle() {
document.getElementById('stylesheet').href = 'style2.css';
}

</script>
in your inputs this:
<input type="button" onclick="changeStyle();"/>

Re: highlight questions in php web form

Posted: Thu Nov 17, 2011 7:42 am
by pmarley2
got it. thanks a lot guys!

--p