PDA

View Full Version : Running javascript on the page


Anonymous
06-11-2005, 11:52 AM
Hi

I am trying to insert a script into the page on version 2 that will let the person change to another url via a drop down box. I have done it in Dreamweaver, and then just copied the code over to the template, but when I go to my directory then, all I get is a blank page. The script is in 2 parts (see below) - if i just have the form on the page, it is fine, but obviously has no functionality. As soon as I add the Javascript part, I get the blank screen and can't for the life of me work out why! :shock: I have tried placing the script code in various places but it makes no difference.

Could anyone suggest what I'm doing wrong please???

Javascript code is :

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>


Any help anyone could give would be gratefully received!!


Thanks
Dixie

and the form html code is :

<form name="form1">
<select name="menu1" onChange="MM_jumpMenu('parent',this,1)">
<option value="www.test1.com">test 1</option>
<option value="www.test2.com">test 2</option>
<option value="www.test3.com">test 3</option>
</select>
</form>

dcb
06-11-2005, 04:16 PM
Enclose your script in {literal} {/literal} tags. "{" and "}" are the tag markers of Smarty and since JScript also uses { and } it will break the Smarty code. the literal tag instructs Smarty to display it's content as it is without any parsing.

Anonymous
06-11-2005, 04:34 PM
Brilliant!! Thanks very much - works a treat now :)