Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2012
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript in table cells

    What is the proper way to include javascript inside a table cell?

    I tried inserting script inside a table with only one row and one data cell.
    That worked.
    Insert more data cells in the row and it fails.

    Why?

    Code:
    <table border="1">
    <tr>
    <td>Text text text</td>
    <td><script type="text/javascript">AudioPlayer.embed("audioplayer_1", {soundFile: "http://example.com/play/tune.mp3"})</script></td>
    <td>?</td>
    </tr>
    </table>
    For those who may ask, the script is for the "Word Press" stand alone mp3 player.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Since when was an audio file tabular data? You should use a more semantic HTML setup instead of the table.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Jun 2012
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sheesh. Could the question get any simpler? Can you answer the question or not?
    If not, don't reply.
    I only used that script as it was handy and as an example.

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    The docs tell you how to do this. "audioplayer_1" needs to be the id for an existing element on the page.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

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