KnowledgeBase/Languages/JavaScript - Cheatsheet for Learning JavaScript
source: above
document.getElementById("myCheckBox").checked;
One reads radio buttons in javascript in a strange way. The easiest way seems to be to give each radio a id="whatever" and then access with code like:
tag <input type="radio" name="choice" id="choiceTag" value="tag" />
title <input type="radio" name="choice" id="choiceTitle" value="title" />
<script type="text/javascript">
var choice = "tag";
if (document.getElementById("choiceTitle").checked) {
choice = "title";
}
</script>
Which sets choice to be either "tag" or "title" depending on which was selected. Then choice can be communicated Ajax style back to the server like this:
liveSearchReq.open("GET", liveSearchRoot + "/tagSearch.php?q=" + document.forms.searchform.q.value + "&choice=" + choice + liveSearchParams);
The PHP at the server reads the variable from $choice
This is running on tagSearch.html but the choice does nothing yet on the server side.
tag <input type="radio" name="choice" id="choiceTag" value="tag" />
title <input type="radio" name="choice" id="choiceTitle" value="title" />
<script type="text/javascript">
var choice = "tag";
if (document.getElementById("choiceTitle").checked) {
choice = "title";
}
</script>
Which sets choice to be either "tag" or "title" depending on which was selected. Then choice can be communicated Ajax style back to the server like this:
liveSearchReq.open("GET", liveSearchRoot + "/tagSearch.php?q=" + document.forms.searchform.q.value + "&choice=" + choice + liveSearchParams);
The PHP at the server reads the variable from $choice
This is running on tagSearch.html but the choice does nothing yet on the server side.
Tags
- javascript
- radio buttons
- live search
See Also
- Thought dynamic cartoons with 6 viewings related by tag "javascript".
- Thought JavaScript based HTML editor with 6 viewings related by tag "javascript".
- Thought tag display and navigation project with 3 viewings related by tag "live search".
- Thought automatic bookmarks and intentional bookmarks with 3 viewings related by tag "live search".
- Thought open source javascript spreadsheet engine with 3 viewings related by tag "javascript".
- Thought Advanced Live Search with 2 viewings related by tag "live search".
- Thought about: TrimSpreadsheet - TrimPath - Trac with 1 viewings related by tag "javascript".
- Thought DHTML is a marketing term with 0 viewings related by tag "javascript".
- Thought Replacing live search with 0 viewings related by tag "live search".
- Thought add groups to the live search with 0 viewings related by tag "live search".
- Thought kewl javascript mp3 player with 0 viewings related by tag "javascript".
- Thought round corners without images with 0 viewings related by tag "javascript".
- Thought javascript zoom with 0 viewings related by tag "javascript".
- Thought The time has come to JavaScript ... or not ... with 0 viewings related by tag "javascript".
- Thought about: Dragable RSS boxes with 0 viewings related by tag "javascript".
- Thought about: How to Develop Web Applications with Ajax, Pt. 1 - WebReference.com - with 0 viewings related by tag "javascript".
- Thought about: PEAR :: Package :: HTML_AJAX with 0 viewings related by tag "javascript".
- Thought about: rich text editing with dojo with 0 viewings related by tag "javascript".
- Thought web spreadsheets with 0 viewings related by tag "javascript".
- Thought Preview of Ajax tag search at fastblogit with 0 viewings related by tag "live search".
- Thought programming of edit tag with 0 viewings related by tag "javascript".
- Thought QA understands the code ! with 0 viewings related by tag "javascript".
- Thought The Live Search and tag list panel with 0 viewings related by tag "live search".
- Thought Announcement: live search in tag or title with 0 viewings related by tag "live search".