Link to home
Start Free TrialLog in
Avatar of pdanese
pdanese

asked on

fancy checkboxes or other toggle-switches

Hi,

is it possible to use javascript (or any other web-development language to make a web-page that contains a toggle switch that changes color upon being pressed.

for example,  press once on a square and the square goes from white to black.  press again and it goes from black to white.  etc. etc.

basically, it behaves like a checkbox, but maybe is easier to see visually.

Thanks for any help!
ASKER CERTIFIED SOLUTION
Avatar of Xxavier
Xxavier
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alexgreen
alexgreen

pdanese

are you wanting it to be available for submitting a form (don't think it's possible) or just as an aesthetic thing (Which X's code wil provide without any problem)

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh dear I was coding late last night and the code I gave you looks terrible, this is better


<table bgColor="#FF0000" width="30" onclick="(/ff0000/.test(bgColor))?bgColor='blue':bgColor='red'">
  <tr>
    <td>&nbsp;&nbsp;</td>
  </tr>
</table>


Alex surely you can add formName.submit() to the onclick

Xx
yep, not thinking straight! soz
looking at the code I submitted late last night neither was I. :-)