473,385 Members | 1,615 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,385 software developers and data experts.

help with show hide in a form

Mel
I have a form with 2 submit buttons (s1 s2) and a list of checkboxes

this is what i want to do:
on a single checkbox select:
i want to display s1

on two or more checkbox selection:
i want to display s2 & hide s1

can you please help ? a simple example is highly appreciated

thanks in advance

Jan 13 '06 #1
1 1679
Mel wrote:
I have a form with 2 submit buttons (s1 s2) and a list of checkboxes

this is what i want to do:
on a single checkbox select:
i want to display s1

on two or more checkbox selection:
i want to display s2 & hide s1

can you please help ? a simple example is highly appreciated


Here is the code:

<html>
<head>

<script language="javascript">
function f_button() {
numberchecked = 0
for(x=0;x<document.myform.length;x++)
if(document.myform.elements[x].type=='checkbox'
&& document.myform.elements[x].checked)
numberchecked++

if (numberchecked==0) {
document.getElementById("button1").style.visibilit y='hidden'
document.getElementById("button2").style.visibilit y='hidden'
document.getElementById("button1").style.display=' none'
document.getElementById("button2").style.display=' none'
}

if (numberchecked==1) {
document.getElementById("button1").style.visibilit y='visible'
document.getElementById("button2").style.visibilit y='hidden'
document.getElementById("button1").style.display=' inline'
document.getElementById("button2").style.display=' none'
}

if (numberchecked>1) {
document.getElementById("button1").style.visibilit y='hidden'
document.getElementById("button2").style.visibilit y='visible'
document.getElementById("button1").style.display=' none'
document.getElementById("button2").style.display=' inline'
}
}
</script>
</head>

<body>
<form name="myform" method="get" action="myscript.php">

<input type="checkbox" name="c1" value="1" onClick="f_button()">
<input type="checkbox" name="c2" value="1" onClick="f_button()">
<input type="checkbox" name="c3" value="1" onClick="f_button()">
<input type="checkbox" name="c4" value="1" onClick="f_button()">
<input type="checkbox" name="c5" value="1" onClick="f_button()">

<hr>

<input id="button1" type="submit" value="s1"
style="visibility: hidden; display: none">
<input id="button2" type="submit" value="s2"
style="visibility: hidden; display: none">

</form>
</body>
</html>

--
Bart

Jan 13 '06 #2

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

Similar topics

13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
3
by: Ryh | last post by:
I have the following scritpt. It hides div layer when mouse is out of the div layer. Inside DIV I have IFRAME box. Unfortuantely it does not work in Mozilla or IE 5.5. It hides div when cursor is...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
10
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have...
5
by: Ed Jay | last post by:
I have a switch statement that controls which of several containers is displayed or not. It currently looks like: function showHelp(n) { show('vhelp'); //makes parent container visible switch...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
4
by: Ron | last post by:
I am having a bit of problem with this code: Dim cmd As New OleDb.OleDbCommand("INSERT INTO help (Name, Email, telephone, description)VALUES('" & txtName.Text & "','" & txtEmail.Text & "','" &...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.