XF 1.5 Adding a bit of javascript to a few select pages

I'm creating a couple of custom Xenforo pages and need to add a bit of Javascript to these pages for Paypal ordering. What is the best way to do this?
 
Yes, think of templates as html documents that you can add pretty much anything you would like to add to a normal html doc, alternatively you can create a .js file and reference it as well.
 
So actually in the process of creating a new Xenforo "page", Xenforo created a new template for me called _page_node.211. I attempted to add my javascript directly to this template in the form:

PHP:
<script type="text/javascript">
<!--
function Dollar (val) {  // force to valid dollar amount
var str,pos,rnd=0;
  if (val < .995) rnd = 1;  // for old Netscape browsers
  str = escape (val*1.0 + 0.005001 + rnd);  // float, round, escape
  pos = str.indexOf (".");
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;
}

function ReadForm (obj1) { // process un-named selects
var i,amt,des,obj,pos,val;
  amt = obj1.baseamt.value*1.0;       // base amount
  des = obj1.basedes.value;           // base description
  for (i=0; i<obj1.length; i++) {     // run entire form
    obj = obj1.elements[i];           // a form element
    if (obj.type == "select-one" &&   // just get selects
        obj.name == "") {             // must be un-named
      pos = obj.selectedIndex;        // which option selected
      val = obj.options[pos].value;   // selected value
      pos  = val.indexOf ("@");       // price set?
      if (pos > 0) amt = val.substring (pos + 1)*1.0;
      pos  = val.indexOf ("+");       // price increment?
      if (pos > 0) amt = amt + val.substring (pos + 1)*1.0;
      pos  = val.indexOf ("%");       // percent change?
      if (pos > 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
      if (des.length == 0) des = val;
      else des = des + ", " + val;    // accumulate value
    }
  }
  obj1.item_name.value = des;
  obj1.amount.value = Dollar (amt);
  if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);
}
//-->
</script>
But it doesn't seem to work. What am I doing wrong?
 
It's hard to say without seeing it all in context at your site.

I have a small amount of time at the moment so if you give me admin credentials temporarily at your site I can take a look and see if I can sort out your issue and explain the problem to you.

Start a convo if you would like.
 
Top Bottom