0

I have a HTML form with some fields. One field is price that is changed many times.

I can get price from price.php

Price.php is in my root and after some calculation it echoes price. (all calculation is in this file and it just can echoes price).

Here is my html form field:

<input type="text" id="price" disabled="">

Please help me to update value of this input field every 5 seconds (if price changes). I don't want refresh page. Only updating this field automatically every 5 seconds.

I don't know maybe javascript can help or something else. Anyway if you provide me full working code is very better because I don't know javascript. I only know HTML.

Thank you.

mplungjan
  • 169,008
  • 28
  • 173
  • 236
Joe
  • 1
  • 2
    http://stackoverflow.com/questions/5687600/jquery-call-ajax-every-10-seconds – SeanKelleyx Feb 24 '16 at 16:10
  • Welcome to SO. Please visit the [tour] and the [help] to see what and how to ask here. Hint: Show code or your question will be voted down and likely closed. We are not a coding service – mplungjan Feb 24 '16 at 16:10
  • Hey mplungjan, it was not answered there. That link is for
    update not input field update.
    – Joe Feb 24 '16 at 16:17
  • Change `$('div.feedback-box').html(feedback);` to `$('#price').val(feedback);` – mplungjan Feb 24 '16 at 16:23
  • Or use `function get_price(){ $.post("price.php" ,function(price){ $('#price').val(price); setTimeout(get_price,5000); }); }; get_price();` – mplungjan Feb 24 '16 at 16:25
  • @mplungjan Thank you very much 2nd code which provided worked. – Joe Feb 24 '16 at 20:03
  • @mplungjan My problem now is " it seems price is updated exactly there in form as a disabled (non editable) text file. But when I do right click and view source, I see this has not been defined as a value for input field. Here is the thing I see when I do view source: that is exactly same in my main html. I need to post price value by user's click on submit button. But currently I think nothing is posted if he submit form. Any suggest or edit of codes? – Joe Feb 24 '16 at 20:13
  • That is how it works – mplungjan Feb 24 '16 at 20:15
  • It will be posted. If you open it in Chrome and click inspect you will see it updates – mplungjan Feb 24 '16 at 20:18

0 Answers0