...

View Full Version : "set as default" check box for a drop down menu item



shumbora
10-27-2006, 02:03 AM
Hello all , Iíve been combing the forums for about an hr now trying to see if some one already asked this but I didnít have much luck but anyway on my web site (http://easyfilesearch.com) I have a few drop down menus where users can choose which web sites they want to search , is there a way to use a check button or something similar so once a user chooses a site they can also choose if they want this item on the drop down menu to be their default item when ever the page loads. Basically a ďset as defaultĒ check box for an item in side a drop down menu. Am not sure if this can even be done but any suggestions will be greatly appreciated

_Aerospace_Eng_
10-27-2006, 02:47 AM
Try this for your form

<form method="post" name="form1" onsubmit="javascript:engine1(this.engine.options[this.engine.selectedIndex].value,this.go.value); return false;" >
<select name="engine" class="drop_down">
<option value="-1" selected="selected">Torrent Search</option>
<option value="15">Mini Nova</option>
<option value="26">Torrent Spy</option>

<option value="25">Iso Hunt</option>
<option value="12">Bit Junkie</option>
<option value="18">Demonoid</option>
<option value="10">My Bittorrent</option>
<option value="9">MegaNova</option>
<option value="20">Bit Nova</option>

<option value="2">New Torrents</option>
<option value="4">Piratic</option>
<option value="37">The Pirate Bay</option>
<option value="21">Torrentbox</option>
<option value="1">Torrent Reactor</option>
<option value="24">Torrent Valley</option>

<option value="8">2 Torrents</option>
<option value="28">Monova</option>
<option value="3">Bittorrent.com</option>
<option value="6">Nova Torrents</option>
<option value="7">Linux Tracker</option>
<option value="11">Download Anime</option>

<option value="13">Frozen layer</option>
<option value="22">Torrents Bol</option>
<option value="23">Zomb Tracker</option>
<option value="0">H33t</option>
<option value="38">Smart Torrent</option>
<option value="31">Bt Emuparadise</option>

<option value="27">Indy Torrents</option>
<option value="32">Hunt Park Insider</option>
<option value="35">Ultimate Bit Board</option>
<option value="36">Arab Files</option>
</select>
Set as default engine: <input type="checkbox" onclick="setDefault()" name="dodefault" />
<input name="go" type="text" id="tx1" onKeyUp="document.form2.tx2.value=this.value;document.form3.tx3.value=this.value;">
<input name="submit" type="submit" class="search_button" value="Search" />

</form>
Then add this in between your head tags

<script type="text/javascript">
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function setDefault()
{
if(document.forms['form1'].dodefault.checked)
{
var el = document.forms['form1'].engine.options;
createCookie('default',el.selectedIndex,9999);
}
}
</script>
then change this

function do_onload(){
var cookiename=(typeof persisttype!="undefined" && persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookiecheck=window.get_cookie && get_cookie(cookiename).indexOf("|")!=-1
collecttablinks()
initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
var cookieparse=get_cookie(cookiename).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
expandcontent(tabcontentid, tabobjlinks[whichtab])
}
else
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}
to this

function do_onload()
{
var cookiename=(typeof persisttype!="undefined" && persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookiecheck=window.get_cookie && get_cookie(cookiename).indexOf("|")!=-1
collecttablinks()
initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck)
{
var cookieparse=get_cookie(cookiename).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
expandcontent(tabcontentid, tabobjlinks[whichtab])
}
else expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
if(readCookie('default') != null)
{
document.forms['form1'].engine.selectedIndex = readCookie('default');
}
}

shumbora
10-27-2006, 04:12 AM
hey thanx it works great but I have a question, when I try to add the same ability to the other drop down menus things start to mess up, like if I set a default on torrent search and then set a default on IRC search the first default setting would change to something else. Here take a look http://www.easyfilesearch.com/123.html any idea on how to remedy this problem?

shumbora
10-27-2006, 10:55 PM
ignore my last post , after some trial and error i figured out how to get it to work. and again thanx for your help bro



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum