pleek Posted February 23, 2009 Share Posted February 23, 2009 ok i found this code <script type="text/javascript"> function changeText(){ document.getElementById('boldStuff').innerHTML = 'Fred Flinstone'; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type='button' onclick='changeText()' value='Change Text'/> Now my question is how can i change that so i can input what i want the id "boldStuff" to say? I want to be able to enter in say my name, click "Change Text" and it change dude to my name. Thanks in advanced. Link to comment https://forums.phpfreaks.com/topic/146445-solved-change-txt-from-users-input/ Share on other sites More sharing options...
webster08 Posted February 23, 2009 Share Posted February 23, 2009 <script type="text/javascript"> function changeText(myname){ document.getElementById('boldStuff').innerHTML = myname; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type='button' onclick='changeText("John Doe")' value='Change Text'/> Link to comment https://forums.phpfreaks.com/topic/146445-solved-change-txt-from-users-input/#findComment-768887 Share on other sites More sharing options...
pleek Posted February 23, 2009 Author Share Posted February 23, 2009 um that pretty much does the same thing. What im talking about is like a input form. you type in your name and then click "change text" and the text changes to what you typed in. Link to comment https://forums.phpfreaks.com/topic/146445-solved-change-txt-from-users-input/#findComment-768891 Share on other sites More sharing options...
darkfreaks Posted February 23, 2009 Share Posted February 23, 2009 here is a jquery plugin that is almost what you need. i am sure you can modify it. http://docs.jquery.com/Events/change Link to comment https://forums.phpfreaks.com/topic/146445-solved-change-txt-from-users-input/#findComment-768907 Share on other sites More sharing options...
webster08 Posted February 23, 2009 Share Posted February 23, 2009 um that pretty much does the same thing. What im talking about is like a input form. you type in your name and then click "change text" and the text changes to what you typed in. well you didn't original say that; but i assume this is what you are talking about: <script type="text/javascript"> function changeText(){ var myname = document.getElementById('name').value; document.getElementById('boldStuff').innerHTML = myname; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type="text" id="name"> <input type='button' onclick='changeText()' value='Change Text'/> Link to comment https://forums.phpfreaks.com/topic/146445-solved-change-txt-from-users-input/#findComment-768930 Share on other sites More sharing options...
pleek Posted February 23, 2009 Author Share Posted February 23, 2009 sry and thank you webster, that is exactly what i needed. thanks for the help! Link to comment https://forums.phpfreaks.com/topic/146445-solved-change-txt-from-users-input/#findComment-769631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.