Change text on document onclick

Discussion in 'JavaScript' started by strNoob, Apr 8, 2005.

  1. #1
    I want to allow users to change the font, color, size of text etc... using a form and cookies.

    That part is easy. But instead of just using a basic text form.
    <select>
    <option>red<option>
    <option>green</option>
    <option>blue</option>
    <option>yellow</option>
    etc...

    I wanted to use images in the form that would be clicked then submitted...

    I was thinking something like:
    <img src='red.gif' onclick='someScript(red)'>
    <img src='green.gif' onclick='someScript(green)'>
    <img src='blue.gif' onclick='someScript(blue)'>

    That would change the hidden form value on the fly like:

    <input type='hidden' name='font_color' value='+newcolor+'>

    I've found many examples that changed colors,font size,etc...

    But nothing that could change the value like what I want...

    is it possible?
     
    strNoob, Apr 8, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can change the value of an input element this way:

    <input type="text" id="i1" value="initial value">
    <some-element onclick="document.getElementById('i1').value = Math.random()">
    Code (markup):
    J.D.
     
    J.D., Apr 9, 2005 IP