Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Add a dynamic label to video selected

Add a dynamic label to video selected

Scheduled Pinned Locked Moved JavaScript
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wfzen
    wrote on last edited by
    #1

    I have the following to play a video dynamically by specify the media name and its path. There are multiple links on the same page. A user can click on each link to play a video.

    video 1

    I'd also like to add a label somewhere on the screen so the user knows which video he is playing. I tried the following, by calling getTitle with a number to output the title of the video. The problem is it replace the whole screen instead of placing it somewhere on the screen. So how can I achieve what i need? Thanks for your help,

    function getTitle(tTitle)
    {
    myTitle = ""
    if (tTitle == 1) {
    myTitle = "video 1"
    } else if (tTitle == 2) {
    myTitle = "video 2"
    } else if (tTitle == 3) {
    myTitle = "Video 3"
    } else if (tTitle == 4) {
    myTitle = "Video 4"
    }

    document.write("
    ");
    document.write("Now Playing: " + myTitle);

    }

    J 1 Reply Last reply
    0
    • W wfzen

      I have the following to play a video dynamically by specify the media name and its path. There are multiple links on the same page. A user can click on each link to play a video.

      video 1

      I'd also like to add a label somewhere on the screen so the user knows which video he is playing. I tried the following, by calling getTitle with a number to output the title of the video. The problem is it replace the whole screen instead of placing it somewhere on the screen. So how can I achieve what i need? Thanks for your help,

      function getTitle(tTitle)
      {
      myTitle = ""
      if (tTitle == 1) {
      myTitle = "video 1"
      } else if (tTitle == 2) {
      myTitle = "video 2"
      } else if (tTitle == 3) {
      myTitle = "Video 3"
      } else if (tTitle == 4) {
      myTitle = "Video 4"
      }

      document.write("
      ");
      document.write("Now Playing: " + myTitle);

      }

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      I ran your script through a Javascript Lint validator and adjusted it. writeIn will add a linefeed to the end. The value is not an number NAN, and is a string unless your parseInt(tTitle); But I would of just made a span tag with an ID, and wrote the the span tag for the label, and not document write.

      function getTitle(tTitle)
      {
      myTitle = "";
      if (tTitle === '1') {
      myTitle = "video 1"
      } else if (tTitle === '2') {
      myTitle = "video 2"
      } else if (tTitle === '3') {
      myTitle = "Video 3"
      } else if (tTitle === '4') {
      myTitle = "Video 4"
      }

      document.writeIn('');
      document.write('Now Playing: ' + myTitle);

      W 1 Reply Last reply
      0
      • J jkirkerx

        I ran your script through a Javascript Lint validator and adjusted it. writeIn will add a linefeed to the end. The value is not an number NAN, and is a string unless your parseInt(tTitle); But I would of just made a span tag with an ID, and wrote the the span tag for the label, and not document write.

        function getTitle(tTitle)
        {
        myTitle = "";
        if (tTitle === '1') {
        myTitle = "video 1"
        } else if (tTitle === '2') {
        myTitle = "video 2"
        } else if (tTitle === '3') {
        myTitle = "Video 3"
        } else if (tTitle === '4') {
        myTitle = "Video 4"
        }

        document.writeIn('');
        document.write('Now Playing: ' + myTitle);

        W Offline
        W Offline
        wfzen
        wrote on last edited by
        #3

        Thanks for the help. I still can't get it to work. Chrome Javascript console says Uncaught TypeError: Object #<HTMLDocument> has no method 'writeIn' Can you give hint on the approach you prefer? I'm a newbie on Javascript. Thanks,

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups