Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Display button when checkbox checked?

Reply
Thread Tools

Display button when checkbox checked?

 
 
Targa
Guest
Posts: n/a
 
      01-06-2004
I have a form in which I want to have an button(image) displayed next to a
checkbox when it is checked.
If the box is unchecked, the button should disappear.

How can I do this?

Thanks!



 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      01-06-2004
"Targa" <(E-Mail Removed)> wrote in message
news:AHrKb.58$(E-Mail Removed)...
> I have a form in which I want to have an button(image) displayed next to a
> checkbox when it is checked.
> If the box is unchecked, the button should disappear.
>
> How can I do this?
>
> Thanks!



Perhaps?


<html>
<head>
<title>button.htm</title>
<script language="javascript" type="text/javascript">
<!--
function checker(that) {
if (that.checked) {
toggle.style.display = "";
} else {
toggle.style.display = "none";
}
}
// -->
</script>
</head>
<body>
<form>
<input type="checkbox" name="Box" onclick="checker(this)">
<span id="toggle" style="display:none">
<input type="button" value="Button">
</span>
</form>
</body>
</html>


 
Reply With Quote
 
 
 
 
Targa
Guest
Posts: n/a
 
      01-06-2004
Hey - This works great!

However, I have several fields below the initial checkbox and button. Anyway
to leave those alone?

Thanks!

"McKirahan" <(E-Mail Removed)> wrote in message
news:AOsKb.234567$8y1.1054172@attbi_s52...
> "Targa" <(E-Mail Removed)> wrote in message
> news:AHrKb.58$(E-Mail Removed)...
> > I have a form in which I want to have an button(image) displayed next to

a
> > checkbox when it is checked.
> > If the box is unchecked, the button should disappear.
> >
> > How can I do this?
> >
> > Thanks!

>
>
> Perhaps?
>
>
> <html>
> <head>
> <title>button.htm</title>
> <script language="javascript" type="text/javascript">
> <!--
> function checker(that) {
> if (that.checked) {
> toggle.style.display = "";
> } else {
> toggle.style.display = "none";
> }
> }
> // -->
> </script>
> </head>
> <body>
> <form>
> <input type="checkbox" name="Box" onclick="checker(this)">
> <span id="toggle" style="display:none">
> <input type="button" value="Button">
> </span>
> </form>
> </body>
> </html>
>
>




 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-06-2004
"Targa" <(E-Mail Removed)> wrote in message
news:ketKb.72$(E-Mail Removed)...
> Hey - This works great!
>
> However, I have several fields below the initial checkbox and button.

Anyway
> to leave those alone?
>
> Thanks!


Just put
onclick="checker(this)"
on the checkbox(es) you want.

Or are you asking about the movement of those items when the button appears?
If so, then try:

<html>
<head>
<title>buttton.htm</title>
<script language="javascript" type="text/javascript">
<!--
function checker(that) {
if (that.checked) {
toggle.style.visibility = "visible";
} else {
toggle.style.visibility = "hidden";
}
}
// -->
</script>
</head>
<body>
<form>
<input type="checkbox" name="Box" onclick="checker(this)">
<span id="toggle" style="visibility:hidden">
<input type="button" value="Button">
</span>
<br><input type="checkbox" name="Box" onclick="checker(this)">
</form>
</body>
</html>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASPNET CheckBox and a CheckBox in a TemplateField Jason Huang ASP .Net 0 06-29-2007 12:35 AM
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
disable checkbox list checkbox Vikram ASP .Net 1 01-25-2006 02:59 PM
choosing to display or not to display a checkbox in repeater control. Imran Aziz ASP .Net 4 08-11-2005 05:00 PM
Text on Checkbox below the checkbox tshad ASP .Net 0 04-14-2005 11:26 PM



Advertisments