View Full Version : changing colour of some words in form inputs

10-29-2009, 01:52 PM

I have a search function that looks for specific words in fields from my database and returns them.

I'd like to be able to highlight the search term in my output. So I have some php which inserts CSS styling whenever the search word appears.

However, I'm outputting the results as part of a form, so the text is in inputs and textareas, and the styling doesn't seem to work inside here. All I want to do is simply make the word change colour or something, but not all the words in the input, just some of them if they match.

What I'm getting is:

<textarea name="experience" id="experience" rows="12">3 <span style="color:#00CC33">horse</span>s 17.1 (selling) 15.2 1de and 14.1</textarea>

So the CSS styling is outputting directly into the textarea. Is there any way to make this work?



10-29-2009, 01:56 PM
However, I'm outputting the results as part of a form, Your above approach is invalid. So let me ask, why? Can't you show that text inside a <div> or <p> ?

10-30-2009, 03:11 PM
The text is being shown as part of a form so that the info can be updated immediately from this page, rather than having to then click edit and be taken to a copy of the same page with a form. Saves an extra click.

Any ideas on how this could be done? I'm flexible in terms of how, but I do need the info in a form.