Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question "set as default" check box for a drop down menu item

    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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Try this for your form
    Code:
    <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
    Code:
    <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
    Code:
    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
    Code:
    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');
    	}
    }
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    New Coder
    Join Date
    May 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •