Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10. HTML Form Enhancements from ... > Selecting Radio Buttons Automaticall...

10.4. Selecting Radio Buttons Automatically

10.4.1. Problem

You have a series of radio buttons. The last radio button is labeled “Other” and has a text input field associated with it. Naturally you’d want that radio button to be selected if the user has entered text in the Other field:

<p>How did you hear about us?</p>
<ul id="chooseSource">
    <li>
        <input name="source" id="source1" type="radio" value="www" />
        <label for="source1">Website or Blog</label>
    </li>
    <li>
        <input name="source" id="source2" type="radio" value="mag" />
        <label for="source2">Magazine</label>
    </li>
    <li>
        <input name="source" id="source3" type="radio" value="per" />
        <label for="source3">Friend</label>
    </li>
    <li>
        <input name="source" id="source4" type="radio" value="oth" />
        <label for="source4">Other</label>
        <input name="source4txt" id="source4txt" type="text" />
    </li>
</ul>


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial