www.webdeveloper.com
Results 1 to 3 of 3

Thread: Multiple script call from onClick event. Firefox probs.

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Multiple script call from onClick event. Firefox probs.

    First off, hi all, this is my first post... I'm a bit of a noob to this, so please bear with me.

    I'm using a script (with inner HTML), to swap currencies. My onClick event calls two scripts to change the content of two cells. It works fine in IE, but Firefox... Nothing. I've run firebug, the error returned is "illegal character". This is basically chinese to me. I've copied the code below. Any help or guidance on this matter is very much apreciated. Best regards. Mark

  2. #2
    Join Date
    Jun 2010
    Posts
    2
    <html>
    <head>
    <script type="text/javascript">
    function changeContent1€(){
    var x=document.getElementById('myTable').rows
    var y=x[1].cells
    y[1].innerHTML="1€"
    }
    function changeContent2€(){
    var x=document.getElementById('myTable').rows
    var y=x[2].cells
    y[1].innerHTML="2€"
    }
    function changeContent1&#163;(){
    var x=document.getElementById('myTable').rows
    var y=x[1].cells
    y[1].innerHTML="1&#163;"
    }
    function changeContent2&#163;(){
    var x=document.getElementById('myTable').rows
    var y=x[2].cells
    y[1].innerHTML="2&#163;"
    }
    function changeContent1$(){
    var x=document.getElementById('myTable').rows
    var y=x[1].cells
    y[1].innerHTML="1$"
    }
    function changeContent2$(){
    var x=document.getElementById('myTable').rows
    var y=x[2].cells
    y[1].innerHTML="2$"
    }
    function changeContentRevert1(){
    var x=document.getElementById('myTable').rows
    var y=x[1].cells
    y[1].innerHTML="$22,564m(AD)"
    }
    function changeContentRevert2(){
    var x=document.getElementById('myTable').rows
    var y=x[2].cells
    y[1].innerHTML="$44,895(AD)"
    }
    </script>

    <style type="text/css">
    <!--
    .style1 { font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    }
    .style2 {color: #FFFFFF}
    body {
    margin-left: 0px;
    margin-top: 20px;
    }
    -->
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

    <body>
    <table width="253" height="199" border="0" bgcolor="#FFFFFF" id="myTable">
    <tr>
    <td width="158" height="21" class="style1">Population</td>
    <td width="85" height="21" bgcolor="#CCCCCC" class="style1">502,600</td>
    </tr>
    <tr>
    <td height="21" class="style1">Gross State Product (GSP) </span></td>
    <td height="21" bgcolor="#CCCCCC" class="style1">$22,564m(AD) </td>
    </tr>
    <tr>
    <td height="21" class="style1">GSP Per Capita (PPP) </td>
    <td height="21" bgcolor="#CCCCCC" class="style1">$44,895(AD) </td>
    </tr>
    <tr>
    <td colspan="2" valign="bottom"><form>
    <div align="right"><span class="style1">Change to </span>
    <input name="button2" type="button" onClick="changeContent1&euro;(); changeContent2&euro;();" value="&euro;" />
    <input name="button" type="button" onClick="changeContent1&pound;(); changeContent2&pound;();" value="&pound;" />
    <input name="button3" type="button" onClick="changeContent1$(); changeContent2$();" value="$" />
    <input name="button32" type="button" onClick="changeContentRevert1(); changeContentRevert2();" value="Revert" />
    </div>
    </form>
    <iframe id="NewsWindow" src="canberraquickfacts.html" width="247" height="90" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" style="border: #000000 0px solid;"></iframe></td>
    </tr>
    </table>
    </body>

    </html>

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The function names are invalid. The function name can contain only alphanumeric characters (alphabetic and digits) and the underscore and cannot begin with a number.
    Code:
    // bad
    changeContent1
    // good
    changeContent1Euro

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