Software Archive
Read-only legacy content
17061 Discussions

how can i set input number from input text as variable x ?

zeroman_z_
Beginner
822 Views

how can i set input number from input text as variable x ?

setTimeout(function(){

intel.xdk.player.playSound(intel.xdk.webRoot + "sounds/1.wav");

}, x);

x is variable from input text box how i can do it ?

 

0 Kudos
5 Replies
Swati_S_Intel1
Employee
822 Views

Use getElementById to get the value from the input box.

0 Kudos
zeroman_z_
Beginner
822 Views

sorry any example code ?>

0 Kudos
zeroman_z_
Beginner
822 Views

 $(document).on("click", ".uib_w_3", function(evt)
    {
        var x = document.getElementById("input");
        x=x*1000 ;
      setTimeout(function() { intel.xdk.player.playSound(intel.xdk.webRoot + "sounds/1.wav"); }, x);
        intel.xdk.player.playSound(intel.xdk.webRoot + "sounds/1.wav");
        
    });

>>>>>> not work 

0 Kudos
Swati_S_Intel1
Employee
822 Views

First of all, as I mentioned in the other thread the intel.xdk.webRoot will not work. Use this code to get the webroot path. 

// get the webroot 
        var rootpath = window.location.href ;
        rootpath = rootpath.substring( 0, rootpath.lastIndexOf('/') ) ;
        
        // if it is a real iOS device the webroot is "/"
        var ua = navigator.userAgent; 
        if( !window.tinyHippos && ua.match(/(ios)|(iphone)|(ipod)|(ipad)/ig) ) { // it's not an emulator and it's iOS  
            rootpath = "" ;
        }
        

Next, for your text input box value, you have to specify ID for the input box, like this : 

<input id="settime" type="text">

and in Javascript get the value of the input box through getElementByID like this:

var x= document.getElementById("settime").value;

 

If you are new to HTML5 I would encourage you to learn from W3schools.com

0 Kudos
zeroman_z_
Beginner
822 Views

thanks too much :)

0 Kudos
Reply