Jump to content

Recommended Posts

hi,

if i have a form

<form>
<input type='text' name='text'>
<input type='text' name='text_color'>
</form>

what i want is when they enter something in text box

it will display it below the form

example:

then under here... and when i enter the color it will change the color...

ne ideas please..
Link to comment
https://forums.phpfreaks.com/topic/29408-automatic-text-changer/
Share on other sites

ok html...

<form>
<input type='text' name='text' onkeyup="updateSpan(this.value);>
<input type='text' name='text_color'>
</form>
<span id="text"></text>

and js in the head section

function updateSpan(val)
{
document.getElementById('text').innerHTML = val;
}

try that...
Might seem messy without a function, but it's easy to run as an example:
[code]

<input type='text' id='text' name='text' onkeyup="document.getElementById('text_result').innerHTML = document.getElementById('text').value;">

<input type='text' id='text_color' name='text_color' onkeyup="document.getElementById('text_result').style.backgroundColor = document.getElementById('text_color').value;">

<span id="text_result" style="background-color: white"></span>

[/code]
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.