Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clickable text to select a Checkbox 5

Status
Not open for further replies.

JennyW

Technical User
Mar 1, 2001
323
CA
Hiee,
I have a Form with a “Checkbox” field.
It looks like this…

[tt][] Send me a copy of my message! [/tt]

I think the checkbox is a little small for the user to select, so I also want the user to be able to select the words [tt](Send me a copy of my message!)[/tt] to make the checkbox selected?

Here’s my url…


Here’s the code I’m presently using, but it’s not working out.

[tt]<font color=&quot;#CCCC00&quot; size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot; [red]onClick=&quot;SendAutoResponse[0].checked=true;&quot; style=&quot;CURSOR: hand&quot;[/red]>[/tt]

Thanks,
Jenny
 
change it to: onClick=&quot;WantAutoReply.checked=true;&quot;
as that was what you called the check box
 
Hi Jenny,

Be aware that Netscape 4.x don't supports onclick in font tag, so i will suggust to put them in the <A> tag,

<A href=&quot;javascript:void(0)&quot;
onClick=&quot;WantAutoReply.checked=true;&quot;
style=&quot;TEXT-DECORATION: none&quot;>

hope this helps,
Chiu Chan
WebMaster & Software Engineer
emagine solutions, inc
cchan@emagine-solutions.com
 
Hi guys!
Pepper, shmmeee or anyone else.

Pepper, I tried your code and it kinda worked.
When I select the text…[tt]Send me a copy of my message![/tt], my checkbox IS selected, but if I select the text again (to GET RID of the checkbox selection) nothing happens and the checkbox stays selected. If I want to de-select the checkbox I have to click on the actual box.

Here's my new url for my Form...


Here’s the code I’m using…
Clickable text code = purple
[tt]
<tr>
<td>
</td>
<td>
<input type=checkbox name=&quot;WantAutoReply&quot;>

<A href=&quot;javascript:void(0)&quot;onClick=&quot;WantAutoReply.checked=true;&quot; style=&quot;TEXT-DECORATION: none&quot;>
<font color=&quot;#CCCC00&quot; size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Send me a copy of my message!</font></a>
</td>
</tr>[/tt]

Also,
What can I do if I want to make the whole table row clickable?
Do I put code in the <tr> tag?


Thanks for reading!
Jenny
 
Hi Jenny,
you want to call a function in your onClick like this:

function togcheck()
{
if(WantAutoReply.checked==true)
WantAutoReply.checked=false;
else
WantAutoReply.checked=true;
}


then onClick=&quot;togcheck();&quot;

I'm not sure about the table row question, sorry.
 
Jenny,
I've tried a couple of things for the clickable table row, and putting onClick into the <tr> tag seems to work in IE but not in Netscape (I'm using NN 4.75 on UNIX though) hope this helps :)
 
Hiee!!
shmmeee,

I can't figure out how to apply your code. I don't know where to put it?

Here's my page...


I'm not sure where to put the following code?
[tt]
function togcheck()
{
if(WantAutoReply.checked==true)
WantAutoReply.checked=false;
else
WantAutoReply.checked=true;
}
[/tt]

Do I put it in the <head> tag and in between <script> tags? I'm lost here.

This is where I put my onclick command...
I'm know it's wrong, but again, I'm lost. Ahhhh!

<tr>
<td>
</td>
<td>
<input type=checkbox name=&quot;WantAutoReply&quot;>

<A href=&quot;javascript:void(0)&quot;onClick=&quot;togcheck();&quot;>

<font color=&quot;#CCCC00&quot; size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Send me a copy of my message!</font></a>
</td>
</tr>
[/tt]
Thanks for reading.
Jenny
 
Try it like this, for some reason I cannot get it to work as a function though, but this works

<A href=&quot;javascript:void(0)&quot; style=&quot;TEXT-DECORATION: none&quot; onClick=&quot;if(WantAutoReply.checked==true)
WantAutoReply.checked=false;
else
WantAutoReply.checked=true;
&quot;>

Tim
 
HI Jenny,
that function woudn't work anyway. I see you've already had an answer, but I found out what you were doing wrong you had the onClick outside of the <a> tag. if you replace your previous onclick (onClick=&quot;WantAutoReply.checked=true;&quot;) with either the bit of code CFEmbanet gave you or with onClick=&quot;togcheck();&quot; and then put this function in instead of my previous answer:
Code:
function togcheck()
{
    if(document.form1.WantAutoReply.checked==true)
         document.form1.WantAutoReply.checked=false;
    else
         document.form1.WantAutoReply.checked=true;
}

I hope that's clear. Basically either will work but you need to replace your previous onClick. Come back if there's anything you need help with. :)

Iain
 
Wouldn't WantAutoReply.checked = !WantAutoReply.checked works as well, without the if statement? I've never has a reason to use it, but it seems as if it ought to work. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top