www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript not working in firefox

  1. #1
    Join Date
    Apr 2007
    Posts
    89

    Question Javascript not working in firefox

    hi guys can someone have a look at this and tell me why the script does not work in fire fox as it works fine in IE.



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>PONY EXPRESS HOME</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="style.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">

    var keylist="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"


    function generatepass(plength){
    temp=""
    for (i=0;i<plength;i++)
    temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
    return temp
    }

    function populateform(enterlength){
    document.pgenerate.id.value=generatepass(enterlength)

    }
    function getvalue(id){
    document.id.value=generatepass(id)
    document.write(id);
    }
    </script>

    <script type="text/javascript">
    <!--
    pricelist = new Array();
    //Create array item for every origin/destination location with the price
    pricelist[0] = new Array('Dublin 1', 'Dublin 1', ' 7.50');
    pricelist[1] = new Array('Dublin 1', 'Dublin 2', ' 7.50');
    pricelist[2] = new Array('Dublin 1', 'Dublin 3', ' 7.50');
    pricelist[3] = new Array('Dublin 1', 'Dublin 4', ' 7.50');
    pricelist[4] = new Array('Dublin 1', 'Dublin 5', ' 20.00');
    pricelist[5] = new Array('Dublin 1', 'Dublin 6', ' 15.00');
    pricelist[6] = new Array('Dublin 1', 'Dublin 7', ' 7.50');
    pricelist[7] = new Array('Dublin 1', 'Dublin 8', ' 7.50');
    pricelist[8] = new Array('dublin 1', 'Dublin 9', ' 20.00');
    pricelist[9] = new Array('Dublin 1', 'Dublin 10', ' 20.00');
    pricelist[10] = new Array('Dublin 1', 'Dublin 11', ' 20.00');
    pricelist[11] = new Array('Dublin 1', 'Dublin 12', ' 20.00');

    function getPrice() {

    originObj = document.getElementById('origin');
    destinObj = document.getElementById('destin');

    document.getElementById('input122').value = originObj.value;
    document.getElementById('input12').value = destinObj.value;

    priceAmt = false;

    //If price still not set, iterate through array
    if (!priceAmt) {
    for (i=0; i<pricelist.length; i++) {
    if (pricelist[i][0]==originObj.value && pricelist[i][1]==destinObj.value) {
    priceAmt = pricelist[i][2];
    }
    }
    }

    //If price still not set, iterate through array, reversing values
    if (!priceAmt) {
    for (i=0; i<pricelist.length; i++) {
    if (pricelist[i][1]==originObj.value && pricelist[i][0]==destinObj.value) {
    priceAmt = pricelist[i][2];
    }
    }
    }

    //Set the price
    document.getElementById('price').value = priceAmt;
    }

    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    <script language="JavaScript">
    <!--
    function sendData() {
    var data = document.mf.data.value;
    var url = "confirm-order.htm";

    document.location.href = url + "?" + data;
    return false;

    }

    function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }
    //-->
    </script>

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473
    First step is to open the JavaScript console and look for errors. Select Tools|JavaScript Console and look for errors.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles