Results 1 to 3 of 3

Thread: Alternating text value

  1. #1
    Join Date
    Apr 2007
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Alternating text value

    How can I make a piece of text alternate between two values.

    For example: a default value (in a text box?) is 'even' when the page loads but when I click a button it changes to 'odd'. If I click the button again it returns to 'even' and so on, alternating between odd and even.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    <form action="#">
    <div>
    <input name="even_odd" type="text" readonly value="even"><br>
    <input type="button"
    onclick="var e=this.form.elements['even_odd'];
    e.value=e.value=='odd'?'even':'odd';"
    value="Toggle">
    </div>
    </form>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2007
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    works great thanks, even managed to alter it for another page that does not use forms.

    MANY THANKS

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •