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. Quote Link to comment 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'/> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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'/> Quote Link to comment 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! 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.