SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help with 'show/hide' Script

    Hi,

    I am trying to modifiy some javascript that controls a search form. Currently the script 'hides' or displays search options depending on a user's selection. (ie. If a user selects the phonesearch radio button, options for the phone search are displayed in a drop down. Similarily, if a user selects websearch, options are displayed to search the web).

    The problem with this script is, if a user hits the back button, the radio button selection stays the same, but the search options are changed to the default display. (eg. if a user has selected web search and hits back after performing the search, the raido button for web will be selected but the phone search options will be displayed).

    I am hoping there is a way to fix this?


    Code JavaScript:
    // show-hide help
     
    var subs_array = new Array("phonesearch", "websearch");// Put the id's of your hidden divs in this array
     
    function displaySubs(the_sub){
    	if (document.getElementById(the_sub).style.display==""){
    	document.getElementById(the_sub).style.display = "none";return
      }
      for (i=0;i<subs_array.length;i++){
    	var my_sub = document.getElementById(subs_array[i]);
    	my_sub.style.display = "none";
    	}
      document.getElementById(the_sub).style.display = "";
     
      }
     
    function displaySearch() {
    	if (document.searchOptions.searchradio[0].checked== true){
    		document.getElementById("phonesearch").style.display = "";
    		document.getElementById("websearch").style.display = "none";		
    	}
     
    	else if (document.searchOptions.searchradio[1].checked== true){
    		document.getElementById("websearch").style.display = "";
    		document.getElementById("phonesearch").style.display = "none";	
    	}
     
    }
     
    window.onload = function(e) {
     
    	  document.searchOptions.searchradio[0].checked= true;	
     
    }

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can anyone shed some light on this?


Bookmarks

Posting Permissions

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