brown2005 Posted December 4, 2006 Share Posted December 4, 2006 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 boxit will display it below the formexample: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 More sharing options...
ToonMariner Posted December 5, 2006 Share Posted December 5, 2006 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 sectionfunction updateSpan(val){ document.getElementById('text').innerHTML = val;}try that... Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135238 Share on other sites More sharing options...
brown2005 Posted December 5, 2006 Author Share Posted December 5, 2006 Hi, I have tried that but nothing happens when i write in the box Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135361 Share on other sites More sharing options...
alpine Posted December 5, 2006 Share Posted December 5, 2006 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] Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135402 Share on other sites More sharing options...
brown2005 Posted December 5, 2006 Author Share Posted December 5, 2006 hi, yeah thats cool and i can use that... but the second box changes the background color at the mo, not the text color...ne ideas please? Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135573 Share on other sites More sharing options...
alpine Posted December 5, 2006 Share Posted December 5, 2006 Sorry, my misunderstanding - anyhow it's just to change the style attribute to color instead:style.backgroundColor --> style.color Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135704 Share on other sites More sharing options...
brown2005 Posted December 5, 2006 Author Share Posted December 5, 2006 yeah cool, thanks for all your help mate, is there somewhere that like has a list of the different things you can change with javascript, i.e. font size, align, font type, font weight, etc... Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135712 Share on other sites More sharing options...
artacus Posted December 5, 2006 Share Posted December 5, 2006 Yeah, whatever you can style with CSS. Link to comment https://forums.phpfreaks.com/topic/29408-automatic-text-changer/#findComment-135730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.