Jump to content

pass javascript output to a php variable


beanymanuk

Recommended Posts

I want to pass the result that appears in the div videotime to a php variable which I can then use to add the data to my database

How can I do this?

 

<p>position:</p><div id="videotime"></div>

<script type="text/javascript">
  // get video element
  var video = document.getElementsByTagName("video")[0];
  function writeVideoTime(t) {
    document.getElementById("videotime").innerHTML=t;
  }
</script>

Link to comment
Share on other sites

As was I. <video> is a tag? So why not get it by name?

 

http://developer.apple.com/safari/library/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/ControllingMediaWithJavaScript/ControllingMediaWithJavaScript.html

 

Excerpt:

 


<!DOCTYPE html>

<html>

  <head>

    <title>Simple JavaScript Controller</title>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <script type="text/javascript">



       function playPause() {

        var myVideo = document.getElementsByTagName('video')[0];

         if (myVideo.paused)

            myVideo.play();

         else

            myVideo.pause();

       }



       function makeBig() {

          var myVideo = document.getElementsByTagName('video')[0];

          myVideo.height = (myVideo.videoHeight * 2 ) ;

        }

       function makeNormal() {

          var myVideo = document.getElementsByTagName('video')[0];

          myVideo.height = (myVideo.videoHeight) ;

        }



    </script>

  </head>



  <body>

     <div class="video-player" align="center">

      <video src="myMovie.m4v" poster="poster.jpg" ></video>

      <br>

      <a href="javascript:playPause();">Play/Pause</a> <br>

      <a href="javascript:makeBig();">2x Size</a> |

      <a href="javascript:makeNormal();">1x Size</a> <br>

     </div>

  </body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.