none
Search Bar issues (HTML script) RRS feed

  • Question

  • You guys were a great help last time so I figured I'd try again.  Example below, we implemented a search bar to search for manuals within our SharePoint.  Basically every button randomly stopped working and no one knows why.  I did do the coding myself and I'm not really the best at it so I'm sure there is a mistake.  My question is if there is an easy way to recreate this or if anyone can see any red flags in the coding? 

    All help is appreciated, thanks!

    <div onkeydown="javascript:if (event.keyCode == 13) manualSubmit()">
     <div style="padding-bottom: 10px;">
      <p><a href="https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/_layouts/15/start.aspx#/_layouts/15/viewlsts.aspx" target="_blank">explore manuals (except Homag, Weeke and One-Homag)</a> | <a href="https://stilesmachinery-my.sharepoint.com/personal/servicemailbox_stilesmachinery_com/_layouts/15/start.aspx#/_layouts/15/viewlsts.aspx" target="_blank">explore Homag, Weeke, and One Homag  manuals</a></p></div>
      <table width="400" border="0" cellpadding="1" cellspacing="1">
        <tr>
          <td width="191" valign="top">Manufacturer</td>
          <td width="188"><p>
            <select name="mfg" type="text">
              <option value="Aiken_Controls" selected="selected">Aiken Controls</option>
              <option value="Altendorf" selected="selected">Altendorf</option>
              <option value="Arminius">Arminius</option>
              <option value="Axxis">Axxis</option>
              <option value="Bargstedt">Bargstedt</option>
              <option value="Baumer">Baumer</option>
              <option value="Belfab">Belfab</option>
              <option value="Belotti">Belotti</option>
              <option value="Brandt%20up%20to%20ms30000">Brandt &le; ms30000</option>
              <option value="Brandt%20from%20ms30001%20up">Brandt &ge; ms30001</option>
              <option value="Buerkle">Buerkle</option>
              <option value="Buetfering">Buetfering</option>
              <option value="Cefla">Cefla</option>
              <option value="CF_Nielsen">CF Nielsen</option>
              <option value="CLT_Trim">CLT Trim</option>
              <option value="CMB">CMB</option>
              <option value="Deal_Metal">Deal Metal</option>
              <option value="Dieffenbacher">Dieffenbacher</option>
              <option value="Doucet">Doucet</option>
              <option value="DVT">DVT</option>
              <option value="Espana">Espana</option>
              <option value="Fanuc">Fanuc</option>
              <option value="Fladder">Fladder</option>
              <option value="Friz">Friz</option>
              <option value="Gannomat">Gannomat</option>
              <option value="Gottschild">Gottschild</option>
              <option value="Grotefeld">Grotefeld</option>
              <option value="Hecht">Hecht</option>
              <option value="Heesemann">Heesemann</option>
              <option value="Heian">Heian</option>
              <option value="HMA">HMA</option>
              <option value="Holzma%20up%20to%20ms30000">Holzma &le; ms30000</option>
              <option value="Holzma%20from%20ms30001%20up">Holzma &ge; ms30001</option>
              <option value="Homag%20up%20to%20ms30000">Homag &le; ms30000</option>
              <option value="Homag%20from%20ms30001%20up">Homag &ge; ms30001</option>
              <option value="Homag_automation_technology">Homag_automation_technology</option>
              <option value="Homag_cnc_processing">Homag_cnc_processing</option>
              <option value="Homag_edge_processing">Homag_edge_processing</option>
              <option value="Homag_panel_dividing">Homag_panel_dividing</option>
              <option value="Homag_surface_processing">Homag_surface_processing</option>
              <option value="HSD">HSD</option>
              <option value="Hymmen">Hymmen</option>
              <option value="IConcept">IConcept</option>
              <option value="Ironwood">Ironwood</option>
              <option value="ISE">ISE</option>
              <option value="Jonsdorf">Jonsdorf</option>
              <option value="Josting">Josting</option>
              <option value="Joulin">Joulin</option>
              <option value="Kentwood">Kentwood</option>
              <option value="KMT">KMT</option>
              <option value="Kraemer">Kraemer</option>
              <option value="Kuper">Kuper</option>
              <option value="Laser_Projection_System">Laser Projection System</option>
              <option value="Leadermac">Leadermac</option>
              <option value="Lerum_Maskin">Lerum Maskin</option>
              <option value="Ligmatech">Ligmatech</option>
              <option value="Maka">Maka</option>
              <option value="Makor">Makor</option>
              <option value="Maw">Maw</option>
              <option value="Mayer">Mayer</option>
              <option value="Merlin">Merlin</option>
              <option value="Metzgar">Metzgar</option>
              <option value="Microtec">Microtec</option>
              <option value="Minda">Minda</option>
              <option value="Mini_Max">Mini Max</option>
              <option value="Nestro">Nestro</option>
              <option value="Nordson">Nordson</option>
              <option value="Northwood">Northwood</option>
              <option value="Nottmeyer">Nottmeyer</option>
              <option value="OMGA">OMGA</option>
              <option value="ORMA">ORMA</option>
              <option value="Pistorius">Pistorius</option>
              <option value="Q_System">Q-System</option>
              <option value="SAC">SAC</option>
              <option value="Espana">Sawtech</option>
              <option value="Schiele">Schiele</option>
              <option value="Schmalz">Schmalz</option>
              <option value="Sorbini">Sorbini</option>
              <option value="Southworth">Southworth</option>
              <option value="Stegherr">Stegherr</option>
              <option value="Systech">Systech</option>
              <option value="System_TM">System TM</option>
              <option value="TigerStop">TigerStop</option>
              <option value="Torwegge">Torwegge</option>
              <option value="Travaini">Travaini</option>
              <option value="Triton">Triton</option>
              <option value="TS_MFG">TS MFG</option>
              <option value="Unique">Unique</option>
              <option value="Vector">Vector</option>
              <option value="Venjakob">Venjakob</option>
              <option value="Vertongen">Vertongen</option>
              <option value="Wadkin">Wadkin</option>
              <option value="Waechter">Waechter</option>
              <option value="Wandres">Wandres</option>
              <option value="Weber">Weber</option>
              <option value="Weeke%20up%20to%20ms30000">Weeke &le; ms30000</option>
              <option value="Weeke%20from%20ms30001%20up">Weeke &ge; ms30001</option>
              <option value="Weima">Weima</option>
              <option value="Weinmann">Weinmann</option>
              <option value="Wemhoener">Wemhoener</option>
            </select>
          </p></td>
        </tr>
        <tr>
          <td valign="top">FILTER BY:</td>
          <td><input type="button" value="All Manuals" onClick="AllItems()"/>
          <input type="button" value="Generic" onClick="Generic()"/></td>
        </tr>
        <tr>
          <td valign="top">MS Number (begins with)</td>
          <td><input type="text" name="msNumber"/>
            OR</td>
        </tr>
        <tr>
          <td valign="top">Serial Number (begins with)</td>
          <td><input type="text" name="MSSerialNbr"/>
            OR</td>
        </tr>
        <tr>
          <td valign="top">MS Description (contains)</td>
          <td><input type="text" name="MSDesc"/>
            OR</td>
        </tr>
        <tr>
          <td valign="top">Company Name (contains)</td>
          <td><input type="text" name="CompanyName"/></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="left"><input type="button" value="Search" onclick="manualSubmit()"/>
          <input type="button" value="Reset" onclick="ClearFields();"/></td>
        </tr>
      </table>
     
    < /div>

    <script type="text/javascript">

    function AllItems()
    {
     var mfg = document.getElementsByName("WPQ2mfg")[0].value;
     var AllItemsUrl = "/TechSupp/Lists/Man" + mfg + "/AllItems.aspx";
     
     window.open(AllItemsUrl, "_blank");
     
    }

    function Generic()
    {
     var mfg = document.getElementsByName("WPQ2mfg")[0].value;
     var GenericUrl = "";

     if (mfg.indexOf("Brandt") != -1){
      GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Brandt/Generic/";
     } else if (mfg.indexOf("Holzma") != -1){
      GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Holzma/Generic/";
     } else if (mfg.indexOf("Homag") != -1){
      GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Homag/Generic/";
     } else if (mfg.indexOf("Weeke") != -1){
      GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Weeke/Generic/";
     } else{
      GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/" + mfg + "/Generic/";
     }
      
     window.open(GenericUrl, "_blank"); 
    }

    function manualSubmit()
    {
     
     var mfg = document.getElementsByName("WPQ2mfg")[0].value;
     var msNumber = document.getElementsByName("WPQ2msNumber")[0].value;
     var MSSerialNbr = document.getElementsByName("WPQ2MSSerialNbr")[0].value;
     var MSDesc = document.getElementsByName("WPQ2MSDesc")[0].value;
     var CompanyName = document.getElementsByName("WPQ2CompanyName")[0].value;
     var builturl = "/TechSupp/Lists/Man" + mfg + "/ManualsFilterResults.aspx?";

     if (msNumber.length != 0){
      builturl = builturl + "msNumber="+ msNumber+"&";
     }

     if (MSSerialNbr.length != 0){
      builturl = builturl + "MSSerialNbr="+ MSSerialNbr+"&";
     }

     if (MSDesc.length != 0){
      builturl = builturl + "MSDesc="+ MSDesc+"&";
     }

     if (CompanyName.length != 0){
      builturl = builturl + "CompanyName="+ CompanyName;
     }

     window.open(builturl, "_blank");
     
    }

    function ClearFields() {

     document.getElementsByName("WPQ2msNumber")[0].value = "";
     document.getElementsByName("WPQ2MSSerialNbr")[0].value = "";
     document.getElementsByName("WPQ2MSDesc")[0].value = "";
     document.getElementsByName("WPQ2CompanyName")[0].value = "";

    < /script>

    Thursday, October 3, 2019 2:34 PM

All replies

  • Thursday, October 3, 2019 2:34 PM
  • Hi,

    In your code, the textbox name "mfg" and use get the value using "document.getElementsByName("WPQ2mfg")[0].value", it will throw the exception, so your code not works.

    Please modify the code as below.

    <div onkeydown="javascript:if (event.keyCode == 13) manualSubmit()">
    	<div style="padding-bottom: 10px;">
    	  <p><a href="https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/_layouts/15/start.aspx#/_layouts/15/viewlsts.aspx" target="_blank">explore manuals (except Homag, Weeke and One-Homag)</a> | <a href="https://stilesmachinery-my.sharepoint.com/personal/servicemailbox_stilesmachinery_com/_layouts/15/start.aspx#/_layouts/15/viewlsts.aspx" target="_blank">explore Homag, Weeke, and One Homag  manuals</a></p>
    	</div>
    	<table width="400" border="0" cellpadding="1" cellspacing="1">
        <tr>
          <td width="191" valign="top">Manufacturer</td>
          <td width="188"><p>
            <select name="mfg" type="text">
              <option value="Aiken_Controls" selected="selected">Aiken Controls</option>
              <option value="Altendorf" selected="selected">Altendorf</option>
              <option value="Arminius">Arminius</option>
              <option value="Axxis">Axxis</option>
              <option value="Bargstedt">Bargstedt</option>
              <option value="Baumer">Baumer</option>
              <option value="Belfab">Belfab</option>
              <option value="Belotti">Belotti</option>
              <option value="Brandt%20up%20to%20ms30000">Brandt &le; ms30000</option>
              <option value="Brandt%20from%20ms30001%20up">Brandt &ge; ms30001</option>
              <option value="Buerkle">Buerkle</option>
              <option value="Buetfering">Buetfering</option>
              <option value="Cefla">Cefla</option>
              <option value="CF_Nielsen">CF Nielsen</option>
              <option value="CLT_Trim">CLT Trim</option>
              <option value="CMB">CMB</option>
              <option value="Deal_Metal">Deal Metal</option>
              <option value="Dieffenbacher">Dieffenbacher</option>
              <option value="Doucet">Doucet</option>
              <option value="DVT">DVT</option>
              <option value="Espana">Espana</option>
              <option value="Fanuc">Fanuc</option>
              <option value="Fladder">Fladder</option>
              <option value="Friz">Friz</option>
              <option value="Gannomat">Gannomat</option>
              <option value="Gottschild">Gottschild</option>
              <option value="Grotefeld">Grotefeld</option>
              <option value="Hecht">Hecht</option>
              <option value="Heesemann">Heesemann</option>
              <option value="Heian">Heian</option>
              <option value="HMA">HMA</option>
              <option value="Holzma%20up%20to%20ms30000">Holzma &le; ms30000</option>
              <option value="Holzma%20from%20ms30001%20up">Holzma &ge; ms30001</option>
              <option value="Homag%20up%20to%20ms30000">Homag &le; ms30000</option>
              <option value="Homag%20from%20ms30001%20up">Homag &ge; ms30001</option>
              <option value="Homag_automation_technology">Homag_automation_technology</option>
              <option value="Homag_cnc_processing">Homag_cnc_processing</option>
              <option value="Homag_edge_processing">Homag_edge_processing</option>
              <option value="Homag_panel_dividing">Homag_panel_dividing</option>
              <option value="Homag_surface_processing">Homag_surface_processing</option>
              <option value="HSD">HSD</option>
              <option value="Hymmen">Hymmen</option>
              <option value="IConcept">IConcept</option>
              <option value="Ironwood">Ironwood</option>
              <option value="ISE">ISE</option>
              <option value="Jonsdorf">Jonsdorf</option>
              <option value="Josting">Josting</option>
              <option value="Joulin">Joulin</option>
              <option value="Kentwood">Kentwood</option>
              <option value="KMT">KMT</option>
              <option value="Kraemer">Kraemer</option>
              <option value="Kuper">Kuper</option>
              <option value="Laser_Projection_System">Laser Projection System</option>
              <option value="Leadermac">Leadermac</option>
              <option value="Lerum_Maskin">Lerum Maskin</option>
              <option value="Ligmatech">Ligmatech</option>
              <option value="Maka">Maka</option>
              <option value="Makor">Makor</option>
              <option value="Maw">Maw</option>
              <option value="Mayer">Mayer</option>
              <option value="Merlin">Merlin</option>
              <option value="Metzgar">Metzgar</option>
              <option value="Microtec">Microtec</option>
              <option value="Minda">Minda</option>
              <option value="Mini_Max">Mini Max</option>
              <option value="Nestro">Nestro</option>
              <option value="Nordson">Nordson</option>
              <option value="Northwood">Northwood</option>
              <option value="Nottmeyer">Nottmeyer</option>
              <option value="OMGA">OMGA</option>
              <option value="ORMA">ORMA</option>
              <option value="Pistorius">Pistorius</option>
              <option value="Q_System">Q-System</option>
              <option value="SAC">SAC</option>
              <option value="Espana">Sawtech</option>
              <option value="Schiele">Schiele</option>
              <option value="Schmalz">Schmalz</option>
              <option value="Sorbini">Sorbini</option>
              <option value="Southworth">Southworth</option>
              <option value="Stegherr">Stegherr</option>
              <option value="Systech">Systech</option>
              <option value="System_TM">System TM</option>
              <option value="TigerStop">TigerStop</option>
              <option value="Torwegge">Torwegge</option>
              <option value="Travaini">Travaini</option>
              <option value="Triton">Triton</option>
              <option value="TS_MFG">TS MFG</option>
              <option value="Unique">Unique</option>
              <option value="Vector">Vector</option>
              <option value="Venjakob">Venjakob</option>
              <option value="Vertongen">Vertongen</option>
              <option value="Wadkin">Wadkin</option>
              <option value="Waechter">Waechter</option>
              <option value="Wandres">Wandres</option>
              <option value="Weber">Weber</option>
              <option value="Weeke%20up%20to%20ms30000">Weeke &le; ms30000</option>
              <option value="Weeke%20from%20ms30001%20up">Weeke &ge; ms30001</option>
              <option value="Weima">Weima</option>
              <option value="Weinmann">Weinmann</option>
              <option value="Wemhoener">Wemhoener</option>
            </select>
          </p></td>
        </tr>
        <tr>
          <td valign="top">FILTER BY:</td>
          <td><input type="button" value="All Manuals" onClick="AllItems()"/>
          <input type="button" value="Generic" onClick="Generic()"/></td>
        </tr>
        <tr>
          <td valign="top">MS Number (begins with)</td>
          <td><input type="text" name="msNumber"/>
            OR</td>
        </tr>
        <tr>
          <td valign="top">Serial Number (begins with)</td>
          <td><input type="text" name="MSSerialNbr"/>
            OR</td>
        </tr>
        <tr>
          <td valign="top">MS Description (contains)</td>
          <td><input type="text" name="MSDesc"/>
            OR</td>
        </tr>
        <tr>
          <td valign="top">Company Name (contains)</td>
          <td><input type="text" name="CompanyName"/></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="left"><input type="button" value="Search" onclick="manualSubmit()"/>
          <input type="button" value="Reset" onclick="ClearFields();"/></td>
        </tr>
      </table>
    </div>
    <script type="text/javascript">
    function AllItems(){
    	var mfg = document.getElementsByName("mfg")[0].value;
    	var AllItemsUrl = "/TechSupp/Lists/Man" + mfg + "/AllItems.aspx";
    	window.open(AllItemsUrl, "_blank");
    }
    function Generic(){
    	var mfg = document.getElementsByName("mfg")[0].value;
    	var GenericUrl = "";
    	if (mfg.indexOf("Brandt") != -1){
    		GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Brandt/Generic/";
    	} else if (mfg.indexOf("Holzma") != -1){
    		GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Holzma/Generic/";
    	} else if (mfg.indexOf("Homag") != -1){
    		GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Homag/Generic/";
    	} else if (mfg.indexOf("Weeke") != -1){
    		GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/Weeke/Generic/";
    	} else{
    		GenericUrl = "https://stilesmachinery-my.sharepoint.com/personal/techsupp_stilesmachinery_com/" + mfg + "/Generic/";
    	}
    	window.open(GenericUrl, "_blank"); 
    }
    function manualSubmit(){
    	var mfg = document.getElementsByName("mfg")[0].value;
    	var msNumber = document.getElementsByName("msNumber")[0].value;
    	var MSSerialNbr = document.getElementsByName("MSSerialNbr")[0].value;
    	var MSDesc = document.getElementsByName("MSDesc")[0].value;
    	var CompanyName = document.getElementsByName("CompanyName")[0].value;
    	var builturl = "/TechSupp/Lists/Man" + mfg + "/ManualsFilterResults.aspx?";
    
    	if (msNumber.length != 0){
    		builturl = builturl + "msNumber="+ msNumber+"&";
    	}
    	if (MSSerialNbr.length != 0){
    		builturl = builturl + "MSSerialNbr="+ MSSerialNbr+"&";
    	}
    	if (MSDesc.length != 0){
    		builturl = builturl + "MSDesc="+ MSDesc+"&";
    	}
    	if (CompanyName.length != 0){
    		builturl = builturl + "CompanyName="+ CompanyName;
    	}
    	window.open(builturl, "_blank");
    }
    
    function ClearFields() {
    	document.getElementsByName("msNumber")[0].value = "";
    	document.getElementsByName("MSSerialNbr")[0].value = "";
    	document.getElementsByName("MSDesc")[0].value = "";
    	document.getElementsByName("CompanyName")[0].value = "";
    } 
    </script>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.



    Friday, October 4, 2019 9:06 AM
    Moderator
  • Hi,

    Would you please provide us with an update on the status of your issue?

    Best Regards,
    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, October 8, 2019 9:18 AM
    Moderator
  • Hi,

    Any update?

    If my reply help you, please mark the reply as answer, it will make others who stuck with the similar issue easier to search for valid solutions in this forum.

    Best regards,
    Dennis

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, October 14, 2019 9:08 AM
    Moderator