dreamci Posted July 18, 2008 Share Posted July 18, 2008 hi i want to make an input text field and when someone writes some value in it, i want to make some calculations with that value and write again without submitting form , i think it is possible can u help me how to make that , i think we should use javascript Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/ Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 javascript, if you want help with the code i am free to help Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593787 Share on other sites More sharing options...
dreamci Posted July 18, 2008 Author Share Posted July 18, 2008 i cant believe this place its like live chat help:) i asked 3 question so far i get answer in a second:) thank you blade can u help me with the code, i know nothing about javascript if you can give me simple example like adding 1 to user input value and showing Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593793 Share on other sites More sharing options...
kenrbnsn Posted July 18, 2008 Share Posted July 18, 2008 This has nothing to do with PHP, moving it to the miscellaneous area. Ken Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593795 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 what calculations? Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593803 Share on other sites More sharing options...
dreamci Posted July 18, 2008 Author Share Posted July 18, 2008 i want to show 2% of the value which user has written in the input field without submitting Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593806 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 ok, i will show you how to get the value from the field and display it underneath without reloading. <script type="text/javascript"> function current() { //get the value from the text field var current = document.getElementById("current").value; //print to the div document.getElementById("preview").innerHTML = current; } </script> <input type="text" onKeyup="current()" id="current"/> <div id="preview"></div> Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593808 Share on other sites More sharing options...
dreamci Posted July 18, 2008 Author Share Posted July 18, 2008 this is exactly what i wanted:) thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593813 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 no problem. Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593815 Share on other sites More sharing options...
dreamci Posted July 18, 2008 Author Share Posted July 18, 2008 blade i cant put this code inside <form></form> tags it gives error but works if its outside of the tags Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593829 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 post your code, and the error Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593830 Share on other sites More sharing options...
dreamci Posted July 18, 2008 Author Share Posted July 18, 2008 canyou check from here, my computer language isnt english so my error message is in my language it gives the error at the left bottom of the page where status stands http://www.turkinteraktif.com/denemehtml.php code is <script type="text/javascript"> function current() { //get the value from the text field var current = document.getElementById("current").value; //print to the div document.getElementById("preview").innerHTML = current*2; } </script> <form> <input type="text" onKeyup="current()" id="current"/> <div id="preview"></div></form> Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593834 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 i am lost of why it isn't working , try asking in the javascript forum Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593843 Share on other sites More sharing options...
dreamci Posted July 18, 2008 Author Share Posted July 18, 2008 thank you anyway blade very usefull still Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-593866 Share on other sites More sharing options...
GingerRobot Posted July 19, 2008 Share Posted July 19, 2008 The problem is that you've named the function and the variable with the same name. Try: <script type="text/javascript"> function timesbytwo() { //get the value from the text field var current = document.getElementById("current").value; //print to the div document.getElementById("preview").innerHTML = current*2; } </script> <form> <input type="text" onKeyup="timesbytwo()" id="current"/> <div id="preview"></div></form> Quote Link to comment https://forums.phpfreaks.com/topic/115501-solved-live-update/#findComment-594043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.