Web Analytics Made Easy -
StatCounter duplicate text field vaule on other text fields - CodingForum

Announcement

Collapse
No announcement yet.

duplicate text field vaule on other text fields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • duplicate text field vaule on other text fields

    Hello everyone, I was attempting to build a search feature on my site that will allow visitors to search different lists of search engines.. My only problem is that i have 3 different text fields for inputting the search criteria and when ever you change the list you have to retype the search criteria. is there a way so that all three text fields can be edited at the same time meaning changing the value of one text field will change all the text field values and vies versa so no retyping of search criteria would be necessary
    Code:
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <script type="text/javascript">
    function doSearch( selectedIndex, searchTerm ) {
       if ( selectedIndex < 0 ) {
          alert("Please select a search engine!");
          return false;
       } else if ( searchTerm == "" ) {
          alert("No search term!");
          return false;
       }
    DoTheSearchInTheFrame(SEARCH_DATA[selectedIndex][1], SEARCH_DATA[selectedIndex][0]);
    }
    
    function engine1( selectedIndex, searchTerm )
    {
       SEARCH_DATA= new Array(4);
       SEARCH_DATA[0]= new Array("Google","http://www.google.com/search?hl=en&q="+escape(searchTerm)+"&btnG=Google+Search");
       SEARCH_DATA[1]= new Array("Yahoo","http://search.yahoo.com/search?p="+escape(searchTerm)+"&fr=yfp-t-500&toggle=1&cop=&ei=UTF-8");
       SEARCH_DATA[2]= new Array("Altavista","http://www.altavista.com/web/results?itag=ody&q="+escape(searchTerm)+"&kgs=1&kls=0");
       SEARCH_DATA[3]= new Array("All The Web","http://alltheweb.com/search?cat=web&cs=iso88591&q"+escape(searchTerm)+"&rys=0&itag=crv&_sb_lang=pref");
        
    
    doSearch( selectedIndex, searchTerm );
       return true;
    }
    
    function DoTheSearchInTheFrame(var_a,var_b)
    {
    eval("document.getElementById('inpage').src=var_a");
    }
    </script>
    <center>
    <form action="index.php" name="searchForm1" target="billy" id="search" 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">Select Search Engine</option>
            <option value="0">Google</option>
      
            </select>
            <input name="go" class="text_field" size="25" maxlength="35" />
            <input name="submit" type="submit" class="search_button" value="Search" />
      </form>
    		
    </center>
    </div>
    <center>
    <form action="index.php" name="searchForm1" target="billy" id="search" 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">Select Search Engine</option>
            <option value="1">Yahoo</option>
      
            </select>
            <input name="go" class="text_field" size="25" maxlength="35" />
            <input name="submit" type="submit" class="search_button" value="Search" />
      </form>
    		
    </center>
    </div>
    <center>
    </center>
    </div>
    </div>
    <center>
    <form action="index.php" name="searchForm1" target="billy" id="search" 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">Select Search Engine</option>
            <option value="3">All The Web</option>
      
            </select>
            <input name="go" class="text_field" size="25" maxlength="35" />
            <input name="submit" type="submit" class="search_button" value="Search" />
      </form>
    		
    </center>
    </div>
    <div align="center">
      <iframe src="http://www.altavista.com/" class="inframe" frameborder="0" id="inpage" style="width:100%;height:600px" border="0"></iframe>
    </div>
    </body>
    </html>
    Any Comments will be greatly appreciated, and thanx in advance.
    Last edited by shumbora; Oct 9, 2006, 04:23 PM. Reason: miss spell

  • #2
    You can't have the same name or id twice unless you are using radio buttons.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>test</title>
    <style type="text/css">
    body {
    text-align:center;
    margin:0;
    padding:0;
    }
    form {
    margin:10px 0 0 0;
    padding:0;
    }
    .inframe {
    width:100%;
    height:600px;
    }
    </style>
    <script type="text/javascript">
    function changeBox(form1,where1,form2,where2,what)
    {
    	document.forms[form1].elements[where1].value = what;
    	document.forms[form2].elements[where2].value = what;
    }
    function doSearch( selectedIndex, searchTerm ) {
       if ( selectedIndex < 0 ) {
          alert("Please select a search engine!");
          return false;
       } else if ( searchTerm == "" ) {
          alert("No search term!");
          return false;
       }
    DoTheSearchInTheFrame(SEARCH_DATA[selectedIndex][1], SEARCH_DATA[selectedIndex][0]);
    }
    
    function engine1( selectedIndex, searchTerm )
    {
       SEARCH_DATA= new Array(4);
       SEARCH_DATA[0]= new Array("Google","http://www.google.com/search?hl=en&q="+escape(searchTerm)+"&btnG=Google+Search");
       SEARCH_DATA[1]= new Array("Yahoo","http://search.yahoo.com/search?p="+escape(searchTerm)+"&fr=yfp-t-500&toggle=1&cop=&ei=UTF-8");
       SEARCH_DATA[2]= new Array("Altavista","http://www.altavista.com/web/results?itag=ody&q="+escape(searchTerm)+"&kgs=1&kls=0");
       SEARCH_DATA[3]= new Array("All The Web","http://alltheweb.com/search?cat=web&cs=iso88591&q"+escape(searchTerm)+"&rys=0&itag=crv&_sb_lang=pref");
        
    
    doSearch( selectedIndex, searchTerm );
       return true;
    }
    
    function DoTheSearchInTheFrame(var_a,var_b)
    {
    document.getElementById('inpage').src=var_a;
    }
    </script>
    </head>
    <body>
    <form action="index.php" name="searchForm1" target="billy" id="torrentsearch1" 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">Select Search Engine</option>
    		<option value="0">Google</option>
    	</select>
    	<input name="go1" class="text_field" size="25" maxlength="35" onkeyup="changeBox('searchForm2','go2','searchForm3','go3',this.value)" />
    	<input name="submit" type="submit" class="search_button" value="Search" />
    </form>
    <form action="index.php" name="searchForm2" target="billy" id="torrentsearch2" 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">Select Search Engine</option>
    		<option value="1">Yahoo</option>
    	</select>
    	<input name="go2" class="text_field" size="25" maxlength="35" onkeyup="changeBox('searchForm1','go1','searchForm3','go3',this.value)" />
    	<input name="submit" type="submit" class="search_button" value="Search" />
    </form>
    <form action="index.php" name="searchForm3" target="billy" id="torrentsearch3" 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">Select Search Engine</option>
    		<option value="3">All The Web</option>
    	</select>
    	<input name="go3" class="text_field" size="25" maxlength="35" onkeyup="changeBox('searchForm1','go1','searchForm2','go2',this.value)" />
    	<input name="submit" type="submit" class="search_button" value="Search" />
    </form>
    <div>
    	<iframe src="http://www.altavista.com/" class="inframe" frameborder="0" id="inpage" name="inpage"></iframe>
    </div>
    </body>
    </html>
    Last edited by _Aerospace_Eng_; Oct 9, 2006, 04:39 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      Wow i never expected an answer to my problem so fast but wow... Problem solved thanx alot brother i really appreciate your help

      Comment


      • #4
        Please don't pm people just get them to look at a thread. Just reply in a post. I had to change a few names of input boxes which might the problem. You may have to make a form action for each box.
        ||||If you are getting paid to do a job, don't ask for help on it!||||

        Comment

        Working...
        X