Imad Posted September 10, 2008 Share Posted September 10, 2008 Hi Guys, I don't know how to make this and thought someone might help. I want the text in the textbox (as the user types), to change the title. For example, the title currently says: Title of Page: [enter text] I want the [enter text] text to change as to what the user types in the textbox as the user types it. Thanks in advanced. Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 10, 2008 Share Posted September 10, 2008 Have you tried just accessing the window.title? Try something like this: JavaScript: function updateTitle(el) { window.title = el.value; } HTML: <input type="text" id="my-title" value="" onblur="updateTitle(this);" /> As you can see, I set it to update the title when your focus goes off the text field, but you can change the event to whatever you like. Quote Link to comment Share on other sites More sharing options...
Imad Posted September 10, 2008 Author Share Posted September 10, 2008 Thanks for your help. I tried modifying what you gave me to work for what I have but didn't go well. I should have clarified it better. I want it to change or update text within the page, or the title of a paragraph and not the actual window title. Here's what I did so far but doesn't seem to work: function updateTitle(replace) { var replace = document.getElementById('replace'); var referred_to = document.getElementById('referred_to'); document.referred_to = replace.innerHTML; } </script> echo "<input class=\"onebartext\" type=\"text\" onblur=\"updateTitle(replace);\" name=\"referred_to\" id=\"referred_to\" tabindex=\"1\" value=\"$referred_to\" /></p>\n"; referred_to is the input box of where the user types and replace is the text that should be replaced as the user types. Best Regards. Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 10, 2008 Share Posted September 10, 2008 So, in your case, you could just assign the value of the referred_to box to the innerHTML of the replace: document.getElementById('replace').innerHTML = document.getElementById('referred_to').value; 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.