javascript in header template?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wtrk
    Senior Member
    • May 2005
    • 306
    • 3.7.x

    javascript in header template?

    when i try and modify the header template with some javascript i get errors when i try and save the template. how do i get the vb to accept the template with the javascript in it?

    this is what i want to add to the template:

    Code:
    <script language="javascript" type="text/javascript">
        function doSearch() {
            if (frm.keyword.value == "") {
                alert("Please enter Search keyword.");
                frm.keyword.focus();
                return (false);
            }
            document.frm.submit();
            return (true);
        }
    </script>
    
    <style type="text/css">
    <!--
    .style1 {
        font-size: 12px;
        font-weight: bold;
    }
    -->
    </style>
    
    <CENTER>
    <table width="257" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="2"><form name=frm method=get action="http://www.xxxxxxxx.com/search/results.php"><input name="keyword" type="text" class="Text" size="50" value="<?=$_GET["keyword"];?>"></td>
          </tr>
          <tr>
            <td width="235" class="GreyText"><nobr><input name="option" type="radio" class="BlueText" value="1" <?if ($_GET["option"]==1) echo "checked";?>>
              MENUS
              <input name="option" type="radio" class="BlueText" value="2" <?if ($_GET["option"]==2) echo "checked";?>>
              REVIEWS <input name="option" type="radio" class="BlueText" value="3" <?if ($_GET["option"]==3 || $_GET["option"]=='') echo "checked";?>>
              BOTH
            <input type=submit name=submit value="Find It"></nobr></td></form>
          </tr>
        </table>
    </CENTER>
    it adds a search box to search another part of my site that is separate from vb.
    Last edited by wtrk; Sun 21 May '06, 8:50am.
  • Scott MacVicar
    Former vBulletin Developer
    • Dec 2000
    • 13286

    #2
    What sort of of errors?

    Template parsing errors or JavaScript errors?

    The javascript that you have there will only work in Internet Explorer and alienate all other browsers.
    Scott MacVicar

    My Blog | Twitter

    Comment

    • wtrk
      Senior Member
      • May 2005
      • 306
      • 3.7.x

      #3
      sorry, they are template parsing errors, the javascript works fine, i use it on other non-vb pages.

      The javascript that you have there will only work in Internet Explorer and alienate all other browsers.
      it works fine for me on my mac with firefox, it worked in safari and in ie, i checked them all.

      Comment

      • Scott MacVicar
        Former vBulletin Developer
        • Dec 2000
        • 13286

        #4
        The empty check shouldn't work since

        frm.keyword.value == ""

        doesn't specify what context frm is, IE assumes its a form where Firefox and Safari should have an error.

        Well what sort of template parsing errors? There is usually an error message associated with it.
        Scott MacVicar

        My Blog | Twitter

        Comment

        • wtrk
          Senior Member
          • May 2005
          • 306
          • 3.7.x

          #5
          this is the error i get editing the template when i save:

          The following error occurred when attempting to evaluate this template:

          Parse error: syntax error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/user/domains/mydomain.com/public_html/forums/includes/adminfunctions_template.php(3537) : eval()'d code on line 217

          This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
          if i select to continue, i get this error and no header is displayed:

          Parse error: syntax error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/user/domains/mydomain.com/public_html/forums/global.php(512) : eval()'d code on line 217

          Comment

          • Scott MacVicar
            Former vBulletin Developer
            • Dec 2000
            • 13286

            #6
            Oh i just looked at your code, you have PHP within the HTML you wish to use, you can't use PHP within template code for security reasons.
            Scott MacVicar

            My Blog | Twitter

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...