www.webdeveloper.com
Results 1 to 6 of 6

Thread: Passing an onclick variable

  1. #1
    Join Date
    Nov 2007
    Posts
    194

    Passing an onclick variable

    I'm trying to pass a variable from onclick() to a function and I really am not sure how to do it. This is what i have but it's not working...any ideas?

    HTML Code:
    <head>
    <script type="text/javascript">
    function chooseSong(pass){
    alert(pass);
    var fo = new FlashObject("xspf_player.swf?autoplay=true&song_url=http://stjohnsuccjonestown.org/download/music/"+pass+".mp3, "myplayer", "200", "15", "7", "#e6e6e6");
    fo.write("flashcontent");
       }
    </script>
    </head>
    
    <body>
    <script type="text/javascript" src="flashobject.js"></script>
    <div id="flashcontent"></div>
    <a href="#" onclick="chooseSong("This String is the Variable");">Click here to pass variable</a>
    </body>

  2. #2
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    HTML Code:
    <a href="#" onclick="chooseSong('This String is the Variable');">Click here to pass variable</a>
    try using different quotes so you don't wind up closing attributes early
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  3. #3
    Join Date
    Nov 2007
    Posts
    194
    nope...still nothing

  4. #4
    Join Date
    Nov 2007
    Posts
    194
    I found my problem, all the quotes on line 5 were screwing it up..it's working now

  5. #5
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    that's what I said!?
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  6. #6
    Join Date
    Nov 2007
    Posts
    194
    it wasn't those quotes, although in the end i'm sure it made a difference, but it was the ones that followed the +pass+

    I had to do this to make it work

    HTML Code:
    	var p1="../flash/xspf_player.swf?autoplay=true&song_title="+title;
    	var p2="&song_url=../download/music/"+filename;
    
    	var whole=p1+p2;
    
    	var fo = new FlashObject(whole, "myplayer", "207", "15", "7", "#F7F9FB");
    	fo.write("player");

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