Ok, I attempted to solve this one on my own and I came to the conclusion that I will have to render the entire page with JavaScript, which needless to say made me very unhappy. So I decided before I go ahead and do it, I'd ask you guys if there is an easier method.
Problem:
I have a page dedicated to searching and it has a set of radio buttons with onClick events to change where the search box is searching, I would like it to be that when click it sets a cookie and on refresh/revisit it will remember where you were searching. I also have a <span> tag which inside is whichever search engine you are using. I.e. "You are searching Google Search." I hope that it can remember that to, it also uses and onClick event. I was wondering if it was possible to do it without rendering the entire page in JavaScript, say something like the area for the form is inside a <span> or <div> tag so thatthe JavaScript can just output it.
Code for the Search:
Code That Makes The Search Work:Code:<form> Google it...<input name="searchselect" onClick="searchswitch_google();makeTxt('currentsearch','You are searching Google Search.');" value="google" type="radio" checked> <br> Yahoo! it...<input name="searchselect" onClick="searchswitch_yahoo();makeTxt('currentsearch','You are searching Yahoo! Search.');" value="yahoo" type="radio"> <br> Microsoft Live! it...<input name="searchselect" onClick="searchswitch_live();makeTxt('currentsearch','You are searching Microsoft Live! Search.');" value="live" type="radio"> <br> Ask it...<input name="searchselect" onClick="searchswitch_ask();makeTxt('currentsearch','You are searching Ask Search.');" value="ask" type="radio"> </form> <br> <form name="search" method="get" action="http://www.google.com/search"> <br> <input class="field" name="q" size="25" maxlength="255" type="text"> <br> <input class="field" value="Search" type="submit"> </form>
Code For The "Current Searching...":Code:function searchswitch_google() { document.forms.search.action='http://www.google.com/search'; } function searchswitch_yahoo() { document.forms.search.action='http://search.yahoo.com/search'; } function searchswitch_live() { document.forms.search.action='http://search.live.com/results.aspx'; } function searchswitch_ask() { document.forms.search.action='http://www.ask.com/web'; }
Code That Makes "Current Searching..." Work:Code:<span id="currentsearch">You are searching Google Search.</span>
Well, I'll wait.Code:function makeTxt(id,txt){ var obj = document.getElementById(id); obj.firstChild?obj.firstChild.data=txt:obj.appendChild(document.createTextNode(txt)) }
-Tim



Reply With Quote


Bookmarks