473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Invisible Submit buttons

I need to make a submit button turn invisible when a checkbox is not
clicked, and visible when it is clicked....I can't figure out a
cross-browser way of doing this.

Can anyone help?

Nov 23 '05 #1
6 6277
Tony R wrote on 18 nov 2005 in comp.lang.javascript:
I need to make a submit button turn invisible when a checkbox is not
clicked, and visible when it is clicked....I can't figure out a
cross-browser way of doing this.


obj.style.visibility='hidden'

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 23 '05 #2
>> I need to make a submit button turn invisible when a checkbox is not
clicked, and visible when it is clicked....I can't figure out a
cross-browser way of doing this.


obj.style.visibility='hidden'


alternately, obj.style.display = 'none'

visibility:hidden keeps the place on the page where the invisible item
should be - you just don't see the item. display:none eliminates the
space too.

Which to use depends on the specific display results desired.

Nov 23 '05 #3
I'm sorry that this reply is extremely n00bish, because I really should
know this stuff, but I haven't done JScript in so long that I've
forgotten a lot of the basics....

How do I define obj as my submit box?

Nov 23 '05 #4
Tony R wrote:
I'm sorry that this reply is extremely n00bish, because I really should
know this stuff, but I haven't done JScript in so long that I've
forgotten a lot of the basics....

How do I define obj as my submit box?


Rather than hiding/showing the submit button, you are better to
disable/enable it. You also need script to disable it in the first
place and also to make sure its state reflects that of the checkbox if
the form is reset. Below is a bit of play code to get you started.

Note that if you check the checkbox the button is enabled, if you
re-load the page most browsers will keep the checkbox checked but the
submit button is disabled. Similarly, resetting the form will make the
checkbox unchecked but not disable the button again (hiding/showing has
exactly the same issues).
<form action="">
<input type="checkbox" onclick="
this.form.theSubmit.disabled = !(this.checked);
">Check me to enable the submit button<br>
<input type="submit" name="theSubmit" disabled>
</form>
PS. Don't give the submit button a name or ID of 'submit'.
--
Rob
Nov 23 '05 #5
RobG wrote on 19 nov 2005 in comp.lang.javascript:
<form action="">
<input type="checkbox" onclick="
this.form.theSubmit.disabled = !(this.checked);
">Check me to enable the submit button<br>
<input type="submit" name="theSubmit" disabled>
</form>


Try this, text input is allowed,
but submitting by pressing <return> is prevented,
till the box is checked:

=======================

<form action="" onsubmit='return false'>

<input type="checkbox"

onclick="
this.form.theSubmit.disabled = !this.checked;
this.form.onsubmit = 'return ' + this.checked;">

Check me to enable the submit button and &lt;return><br>

<input name='theText'><br>
<input type="submit" name="theSubmit"
value="do submit" disabled>

</form>

=======================

btw, this.checked is as good as (this.checked)

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 23 '05 #6
RobG wrote:
Tony R wrote:
I'm sorry that this reply is extremely n00bish, because I really should
know this stuff, but I haven't done JScript in so long that I've
forgotten a lot of the basics....

How do I define obj as my submit box?
Rather than hiding/showing the submit button, you are better to
disable/enable it. You also need script to disable it in the first
place


Yes, but you did not.
and also to make sure its state reflects that of the checkbox if
the form is reset. Below is a bit of play code to get you started.
[...]
<form action="">
<input type="checkbox" onclick="
this.form.theSubmit.disabled = !(this.checked);
">Check me to enable the submit button<br>
Parentheses are unnecessary and attribute values should not include
newline. If this was merely to prevent automatic line-break, use

<input type="checkbox"
onclick="this.form.theSubmit.disabled = !this.checked;"
id="cbSubmit"<label for="cbSubmit"
Check me to enable the submit button</label><br> <input type="submit" name="theSubmit" disabled>
Don't. The form will not be usable without client-side script support.
</form>
PS. Don't give the submit button a name or ID of 'submit'.


True.
PointedEars
Nov 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bob Lehmann | last post by:
Hi, I pretty sure I've seen this problem addressed before, but I can't find any references. The short story is that I have I have multiple submit buttons on a page, each providing different...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
1
by: PCB | last post by:
Hi all, Not sure if this is possible, but can I change the controls of a command button on a per record bases in a subform. In my case, I would like to make a command button visible only if...
6
by: MW de Jager | last post by:
I'm trying to create an html page that will change dynamically. I need to switch html -buttons between visible and invisible. Is there any way I can do this with a script? Regards MW
9
by: Poker Man | last post by:
Hi, I know how to do Sumbit buttons in Forms, and I know how to do custom buttons in Javascript. What I can't seem to find is how to do custom Submit buttons using Javascript! Anybody out...
1
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine...
2
by: rudranee | last post by:
hello, How do i declare multiple submit buttons on a form? and how do i come to know on the next page which button has been clicked? Can i do it in JSP page? Please tell me.
5
by: Alex | last post by:
Hello, I hope I can explain this properly. I'm writing an application with a tabbed-based navigation, and a form which gets filled out by users will be split into 5 subtabs. What I need is...
5
by: Andy B | last post by:
I have 2 TextBoxes and an Add button on a page. When the user fills in the TextBoxes, the values are added to a dataset table. When the page gets done reloading, the TextBoxes are turned into...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.