javascript - How do i allow my rates to be refreshable? -


the bid , offer being defined $bid,$bid1,$bid2. need refreshed every 1 second , located in text field predefined. able put rates in upon selection how them refreshing?

heres code:

start.php

<?php session_start(); $timestamp=time();set_time_limit (0); echo 'welcome trade page <br>';  $_session['u'] = 'seyant'; $_session['p']   = 'se5an123'; $_session['q']   = 'eurates';  $url  = "http://webrates.truefx.com/rates/connect.html?c=eur/usd&f=csv&s=n"; $url1 = "http://webrates.truefx.com/rates/connect.html?c=usd/jpy&f=csv&s=n"; $url2 = "http://webrates.truefx.com/rates/connect.html?c=usd/cad&f=csv&s=n"; $url3 = "http://webrates.truefx.com/rates/connect.html?c=eur/jpy&f=csv&s=n"; $url4 = "http://webrates.truefx.com/rates/connect.html?c=eur/chf&f=csv&s=n"; $url5 = "http://webrates.truefx.com/rates/connect.html?c=gbp/usd&f=csv&s=n"; $url6 = "http://webrates.truefx.com/rates/connect.html?c=aud/usd&f=csv&s=n"; $url7 = "http://webrates.truefx.com/rates/connect.html?c=usd/chf&f=csv&s=n";  // create curl resource      $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output = curl_exec($ch);        // close curl resource free system resources      curl_close($ch);         $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url1);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output1 = curl_exec($ch);        // close curl resource free system resources      curl_close($ch);                 $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url2);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output2 = curl_exec($ch);          // close curl resource free system resources      curl_close($ch);                 $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url3);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output3 = curl_exec($ch);         // close curl resource free system resources      curl_close($ch);                 $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url4);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output4 = curl_exec($ch);         // close curl resource free system resources      curl_close($ch);                 $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url5);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output5 = curl_exec($ch);         // close curl resource free system resources      curl_close($ch);                 $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url6);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output6 = curl_exec($ch);         // close curl resource free system resources      curl_close($ch);                 $ch = curl_init();       // set url      curl_setopt($ch, curlopt_url, $url7);       //return transfer string      curl_setopt($ch, curlopt_returntransfer, 1);       // $output contains output string      $output7 = curl_exec($ch);         // close curl resource free system resources      curl_close($ch);  // example 1  $frag = explode(",", $output);  //echo $frag[2]; //echo $frag[3]; // echo'<br/>'; //echo $frag[4]; //echo $frag[5];  //echo'<br/>'; echo'<br/>'; $bid = $frag[2].$frag[3]; echo 'eur/usd bid '.$bid; echo'<br/>'; $bid1 = $frag[4].$frag[5]; echo 'eur/usd offer '.$bid1;  echo'<br/>';  $frag1 = explode(",", $output1);  //echo $frag[2]; //echo $frag[3];  // echo'<br/>'; //echo $frag[4]; //echo $frag[5];  //echo'<br/>';  $bid2 = $frag1[2].$frag1[3];  echo 'usd/jpy bid '.$bid2;//bid echo'<br/>'; $bid3 = $frag1[4].$frag1[5]; echo 'usd/jpy offer '.$bid3;//offer echo'<br/>';  $frag2 = explode(",", $output2);  //echo $frag[2]; //echo $frag[3]; // echo'<br/>'; //echo $frag[4]; //echo $frag[5]; //echo'<br/>'; $bid4 = $frag2[2].$frag2[3]; echo 'usd/cad bid '.$bid4;//bid echo'<br/>'; $bid5 = $frag2[4].$frag2[5]; echo 'usd/cad offer '.$bid5;//offer echo'<br/>';   $frag3 = explode(",", $output3);   //echo $frag[2];  //echo $frag[3];  // echo'<br/>';  //echo $frag[4]; //echo $frag[5];   //echo'<br/>'; $bid6 = $frag3[2].$frag3[3];  echo 'eur/jpy bid '.$bid6;//bid echo'<br/>'; $bid7 = $frag3[4].$frag[5];  echo 'eur/jpy offer '.$bid7;//offer  echo'<br/>'; $frag4 = explode(",", $output4);   //echo $frag[2];  //echo $frag[3]; // echo'<br/>'; //echo $frag[4]; //echo $frag[5]; //echo'<br/>'; $bid8 = $frag4[2].$frag4[3]; echo 'eur/chf bid '.$bid8; echo'<br/>'; $bid9 = $frag4[4].$frag4[5]; echo 'eur/chf offer '.$bid9;  echo'<br/>';  $frag5 = explode(",", $output5);   //echo $frag[2];  //echo $frag[3]; // echo'<br/>'; //echo $frag[4]; //echo $frag[5]; //echo'<br/>'; $bid10 = $frag5[2].$frag5[3]; echo 'gbp/usd bid '.$bid10; echo'<br/>'; $bid11 = $frag5[4].$frag5[5]; echo 'gbp/usd offer '.$bid11; echo'<br/>'; $frag6 = explode(",", $output6);  //echo $frag[2];  //echo $frag[3];  // echo'<br/>'; //echo $frag[4]; //echo $frag[5];  //echo'<br/>';   $bid12 = $frag6[2].$frag6[3]; echo 'aud/usd bid '.$bid12; echo'<br/>'; $bid13 = $frag6[4].$frag6[5];  echo 'aud/usd offer '.$bid13;  echo'<br/>'; $frag7 = explode(",", $output7);   //echo $frag[2]; //echo $frag[3]; // echo'<br/>'; //echo $frag[4]; //echo $frag[5];   //echo'<br/>';  $bid14 = $frag7[2].$frag7[3];  echo 'usd/chf bid '.$bid14;  echo'<br/>';  $bid15 = $frag7[4].$frag7[5]; echo 'usd/chf offer '.$bid15;  include 'priceadder.php';     ?> <html>      <head>     <script src="http://code.jquery.com/jquery-latest.js"></script>     <script>                        $(document).ready(function() {      $("#bid16").load("start.php");              var refreshid = setinterval(function() {              $("#bid16").load("http://webrates.truefx.com/rates/connect.html?c=eur/usd,usd/jpy,usd/cad,eur/jpy,eur/chf,gbp/usd,aud/usd,usd/chf&f=csv&s=n");              }, 500);              $.ajaxsetup({ cache: false });           });       </script>     </head>   <body>   <div id="bid16"></div>  </body>  </html> 

priceadder.php

 <?php $timestamp=time();set_time_limit (0);  ?>  <!doctype html>  <head><meta charset="utf-8"></head> <body>   <form action="price.php" method="get" id="myform">    <p>symbol : <select name = "selection" id="selection"> <option value="choose one">choose one</option> <option value="1">eur/usd</option> <option value="2">usd/jpy</option> <option value="3">usd/cad</option> <option value="4">gbp/usd</option> <option value="5">eur/jpy</option> <option value="6">eur/chf</option> <option value="7">aud/usd</option> <option value="8">usd/chf</option>  </select></p> <p> date : <input type="datetime" value="<?php echo date("y-m-d ",$timestamp); ?>" name="date"/></p> <p> type : <input type="radio" name="type" value="buy">buy  <input type="radio" name="type" value="sell">sell <p> size : <input type="number"pattern="[0-9]+([\.|,][0-9]+)?" step="0.01"name="size"/></p> <p> bid price : <input id="bidprice" name="bidprice" type="text" value="">  offer price<input id="offerprice" name="offerprice" type="text" value="">  <p> stop loss : <input type="number"step="any" name="stoploss"/></p> <p> take profit : <input type="number"step="any"name="takeprofit"/></p>  <input type="submit" value="submit"/> </form>     <link rel="stylesheet" type="text/css" href="">    <script type="text/javascript">    window.onload=function() {     if (document.getelementbyid) {   document.getelementbyid("selection").onchange=function() { switchme(this); }     }    }     function switchme(snewsel) {    var ind = snewsel.selectedindex;   var txt = document.getelementbyid('bidprice');   var txt2 = document.getelementbyid('offerprice');    switch (ind) {    case 1: // car purchase    txt.value = <?php echo json_encode($bid); ?>;     txt2.value = <?php echo json_encode($bid1); ?>;    break;    case 2: // other purchase    txt.value = <?php echo json_encode($bid2); ?>;   txt2.value = <?php echo json_encode($bid3); ?>;    break;   case 3: // other purchase   txt.value = <?php echo json_encode($bid4); ?> ;   txt2.value = <?php echo json_encode($bid5); ?>;  break;   default:   txt.value='';   break;   }   }   </script>     </body>  </html> 

first of all, need make loop (while/for/foreach) in start.php. same thing many times.

then problem need use setinterval(callback, milliseconds) function :

http://www.w3schools.com/jsref/met_win_setinterval.asp


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -