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
https://forums.phpfreaks.com/topic/123666-help-replace-text-with-textbox-content/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.