javascript - how to show value without clicking on submit button -


i using html5 , javascript .i reading excel file java script , showing output..please analyze code first

 <input type="button" id="btnsubmit" onclick="readdata(1, 2)" value="submit" /> 

 

var xval = 1; var yval = 2      function readdata(x,y) {         x = xval;         y = yval;         try {             var excel = new activexobject("excel.application");             excel.visible = false;             var excel_file = excel.workbooks.open("d:\\test.xls");// alert(excel_file.worksheets.count);             var excel_sheet = excel_file.worksheets("sheet1");             var data = excel_sheet.cells(x, y).value;             //alert(data);             drawwithexcelvalue(data);             xval = xval + 1;         }         catch (ex) {             alert(ex);         } 

now i'm reading file code , showing output code:

function drawwithexcelvalue(val) {      var txtspeed = val; //alert(txtspeed.value);     if (txtspeed !== null) {          itargetspeed = txtspeed;          // sanity checks         if (isnan(itargetspeed)) {             itargetspeed = 0;         } else if (itargetspeed < 0) {             itargetspeed = 0;         } else if (itargetspeed > 80) {             itargetspeed = 80;         }          job = settimeout("draw()", 5);     } } 

q .1 every time click on submit button show me value excel file ,i want didn't have click every time on submit button ..it automatically show values @ time interval 4 seconds.

q :-2 didn't want submit button ,that means when run code automaticaly start running script onload ="readdata(1, 2)" ,but showing 1 value ...how show values time interval ..please help!!!!!

guys if can give me edited code full me

here code surely work ya

<!doctype html> <html lang="en"> <head>     <meta charset="utf-8" />     <title>speedometer html5 canvas</title>      <script src="script copy.js">  </script>  </head> <body onload='draw(0);'>     <canvas id="tutorial" width="440" height="220">             canvas not available.         </canvas>     <div id="divhidden" style="visibility: hidden; width: 0px; height: 0px">         <form id="drawtemp">         <input type="text" id="txtspeed" name="txtspeed" value="20" maxlength="2" />         <input type="button" value="draw" onclick="drawwithinputvalue();">         <input type="file" id="file" onchange="checkfile(this);" />        <input type="button" id="btnsubmit" onclick="readdata(1, 2)" value="submit" />        <button onclick="mystopfunction()">stop meter</button>           </form>     </div> </body> </html>  <script type="text/javascript" language="javascript">       var myvar=setinterval(function(){readdata(1,2)},2000);     function mystopfunction()     {         clearinterval(myvar);     }       function checkfile(sender) {         var validexts = new array(".xlsx", ".xls", ".csv");         var fileext = sender.value;         fileext = fileext.substring(fileext.lastindexof('.'));         if (validexts.indexof(fileext) < 0) {             alert("invalid file selected, valid files of " +                validexts.tostring() + " types.");             return false;         }         else return true;      } var xval = 1; var yval = 2      function readdata(x,y) {         x = xval;         y = yval;         try {             var excel = new activexobject("excel.application");             excel.visible = false;             var excel_file = excel.workbooks.open("d:\\test.xls");// alert(excel_file.worksheets.count);             var excel_sheet = excel_file.worksheets("sheet1");             var data = excel_sheet.cells(x, y).value;             //alert(data);             drawwithexcelvalue(data);             xval = xval + 1;             if(data==null || data=="")             {              mystopfunction();              }             excel.application.quit();         }         catch (ex) {             alert(ex);         }     } </script> 

Comments