|
Post by iDesign on Mar 19, 2009 19:31:45 GMT -5
Okay. I want an input box in a table. When the person types a hex colour code into the box, and presses enter, the table background changes to that colour. www.javascripter.net/faq/backgrou.htmKinda like that. Except the background colour changed is that of the table, and I want an input box, to type a hex colour. See what I mean?
|
|
|
Post by Bobby Hensley on Mar 19, 2009 20:22:30 GMT -5
<table width="500" border="0" cellspacing="1" cellpadding="4" id="changeColor"> <tr> <td align="center" valign="top"> <input name="ColourChange" type="text" id="ColourChange" value="COLOUR" /> <input name="submitColor" type="submit" id="submitColor" onClick="javascript: document.getElementById('changeColor').style.backgroundColor = document.getElementById('ColourChange').value;" /> </td> </tr> </table>
Such as that?
|
|
|
Post by Blind on Mar 19, 2009 20:23:33 GMT -5
EDIT: Bobby beat me
|
|
|
Post by iDesign on Mar 19, 2009 20:35:38 GMT -5
That's good. Only thing is, I have to put a "#" in front of the colour to make it work. Is there a way round this?
|
|
|
Post by Blind on Mar 19, 2009 21:05:18 GMT -5
<table width="500" border="0" cellspacing="1" cellpadding="4" id="changeColor"> <tr> <td align="center" valign="top"> <input name="ColourChange" type="text" id="ColourChange" value="COLOUR" /> <input name="submitColor" value="#" type="submit" id="submitColor" onClick="javascript: document.getElementById('changeColor').style.backgroundColor = document.getElementById('ColourChange').value;" /> </td> </tr> </table>
Try that.
|
|
|
Post by iDesign on Mar 19, 2009 21:28:33 GMT -5
Sorry, doesn't work.
|
|
|
Post by yilduz on Mar 19, 2009 21:36:04 GMT -5
I'm more of a PHP guy than a JS guy, but this seems like it should work. Try this.
<table width="500" border="0" cellspacing="1" cellpadding="4" id="changeColor"> <tr> <td align="center" valign="top"> <input name="ColourChange" type="text" id="ColourChange" value="COLOUR" /> <input name="submitColor" type="submit" id="submitColor" onClick="javascript: document.getElementById('changeColor').style.backgroundColor = '#' + document.getElementById('ColourChange').value;" /> </td> </tr> </table>
|
|
|
Post by iDesign on Mar 19, 2009 21:42:39 GMT -5
Perfect! Thankyou
|
|
|
Post by yilduz on Mar 19, 2009 22:23:05 GMT -5
No problem.
|
|
|
Post by xcessive on Mar 19, 2009 23:50:25 GMT -5
The coding mod in action.
|
|
|
Post by iDesign on Mar 20, 2009 13:47:21 GMT -5
Sure is. Next question... Is there a way to use that colour change system, but with text colour?
|
|
|
Post by yilduz on Mar 20, 2009 16:11:49 GMT -5
Well, let's see...
Try that, see what happens. Not sure it'll work, though.
edit: >_<
|
|
|
Post by iDesign on Mar 20, 2009 17:16:11 GMT -5
I'm not sure you know what I mean =/ I wanted an input box, that changes the colour of some text please =]
|
|
|
Post by yilduz on Mar 20, 2009 19:11:06 GMT -5
I'm not sure you know what I mean =/ I wanted an input box, that changes the colour of some text please =] Yup, you're correct. I did misunderstand. Give me a few minutes.
|
|
|
Post by iDesign on Mar 21, 2009 4:54:03 GMT -5
No problem.
|
|