Jump to content

[Help] replace text with textbox content


Imad

Recommended Posts

Hi Guys, I don't know how to make this and thought someone might help. :D 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.