Canman2005 Posted October 17, 2007 Share Posted October 17, 2007 Hi all Does anyone know where I can get a script which displays on screen a copy what i''m typing into a form field without refreshing the page. So as I type, the text appears. Can anyone help? Thanks in advance Ed Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 you can start here: http://www.w3schools.com/jsref/jsref_onkeyup.asp then you can use the onkeyup to update content in a div Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted October 17, 2007 Author Share Posted October 17, 2007 cool thanks im a php programmer, not a javascript progarmmer, so how would I go about doing an update to a div from the keyup function? thanks Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 http://www.google.com/search?source=ig&hl=en&rlz=&q=javascript+update+div+onkeyup Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted October 17, 2007 Author Share Posted October 17, 2007 thanks everyone i have hunted around, but cannot find what im trying to do does anyone else have any suggestions? Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted October 17, 2007 Author Share Posted October 17, 2007 found one simple <script language="JavaScript"> function preview(id1, id2){ var NewText = document.getElementById(id1).value; splitText = NewText.split(/\n/).join("<br />"); var DivElement = document.getElementById(id2); DivElement.innerHTML = splitText; } </script> <form action="#"> <label>Name:</label> <input type="text" id="name" onkeyup="preview('name', 'preview-name');" /> <label>Phone:</label> <input type="text" id="phone" onkeyup="preview('phone', 'preview-phone');" /> </form> <h2>Preview</h2> <dl> <dt>Name:</dt> <dd id="preview-name"></dd> <dt>Phone:</dt> <dd id="preview-phone"></dd> </dl> Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 see, there ya go, easy enough right? Quote Link to comment 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.