473,503 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CheckBox using an Onclick Event, then Posting Back

I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't figure
out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')" language="javascript"
/>

ANy advice?
Nov 19 '05 #1
7 5452
Ryan,

If you function is returning true the postback should certainly fire. May we
see your CheckClosed javascript? The problem must lie there.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't figure
out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?

Nov 19 '05 #2
function CheckClosed(checkbox)
{
...var chkBox = document.getElementById(checkbox);
...if(chkBox.checked == true)
...{
.....if(confirm("Changing this Package to Closed will cause all Items within
the Package to be closed.\n Press Ok to Continue."))
........return true;
.....else
........return false;
.....}
...else
...return true;
}

The ConfimationBox pops up correctly, and works fine. It just doesn't
postback. I even hardcoded a "Return true;" at the top of the function and
it didn't fire.

/RT
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:Oi**************@tk2msftngp13.phx.gbl...
Ryan,

If you function is returning true the postback should certainly fire. May
we see your CheckClosed javascript? The problem must lie there.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't figure
out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?


Nov 19 '05 #3
Ryan,

Funny, I sure don't see anything wrong with your code. And placing a return
true at the top of the function is what I would have suggested next. Just to
get an exact description of the behaviour, the page does not post back at
all, or it posts back but the checkbox's event doesn't fire?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
function CheckClosed(checkbox)
{
..var chkBox = document.getElementById(checkbox);
..if(chkBox.checked == true)
..{
....if(confirm("Changing this Package to Closed will cause all Items
within the Package to be closed.\n Press Ok to Continue."))
.......return true;
....else
.......return false;
....}
..else
..return true;
}

The ConfimationBox pops up correctly, and works fine. It just doesn't
postback. I even hardcoded a "Return true;" at the top of the function and
it didn't fire.

/RT
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:Oi**************@tk2msftngp13.phx.gbl...
Ryan,

If you function is returning true the postback should certainly fire. May
we see your CheckClosed javascript? The problem must lie there.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't
figure out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?



Nov 19 '05 #4
you only want to return if the user click no, otherwise you want to run the
next statement. try:

chkClosed.Attributes.Add("onClick","if (!CheckClosed('" +
chkClosed.ClientID + "') return;");
-- bruce (sqlwork.com)
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't figure
out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?

Nov 19 '05 #5
That did it!

Why did this work and not the previous statement I had?

My code worked on a submit button, but not a CheckBox... hmm

Thanks for the help man!

/RT
"Bruce Barker" <br******************@safeco.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
you only want to return if the user click no, otherwise you want to run
the next statement. try:

chkClosed.Attributes.Add("onClick","if (!CheckClosed('" +
chkClosed.ClientID + "') return;");
-- bruce (sqlwork.com)
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't figure
out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?


Nov 19 '05 #6
a submit button posts automatically, you cancel in client script by
returning a false on the onclick event. asp.net controls like a checkbox
postback by calling a function __doPostback(), which in turn calls
form.submit(); so with the checkbox you only excute a return to cancel the
postback, but with a submit you return the value true or false to control
the cancel.

-- bruce (sqlwork.com)

"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:Or**************@TK2MSFTNGP15.phx.gbl...
That did it!

Why did this work and not the previous statement I had?

My code worked on a submit button, but not a CheckBox... hmm

Thanks for the help man!

/RT
"Bruce Barker" <br******************@safeco.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
you only want to return if the user click no, otherwise you want to run
the next statement. try:

chkClosed.Attributes.Add("onClick","if (!CheckClosed('" +
chkClosed.ClientID + "') return;");
-- bruce (sqlwork.com)
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't
figure out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?



Nov 19 '05 #7
Bruce,

Great information. Thanks!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Bruce Barker" <br******************@safeco.com> wrote in message
news:Oh**************@TK2MSFTNGP14.phx.gbl...
a submit button posts automatically, you cancel in client script by
returning a false on the onclick event. asp.net controls like a checkbox
postback by calling a function __doPostback(), which in turn calls
form.submit(); so with the checkbox you only excute a return to cancel the
postback, but with a submit you return the value true or false to control
the cancel.

-- bruce (sqlwork.com)

"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:Or**************@TK2MSFTNGP15.phx.gbl...
That did it!

Why did this work and not the previous statement I had?

My code worked on a submit button, but not a CheckBox... hmm

Thanks for the help man!

/RT
"Bruce Barker" <br******************@safeco.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
you only want to return if the user click no, otherwise you want to run
the next statement. try:

chkClosed.Attributes.Add("onClick","if (!CheckClosed('" +
chkClosed.ClientID + "') return;");
-- bruce (sqlwork.com)
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.

When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't
figure out how to do this.

Here is the code I use to put the OnClick event on the CHeckbox.

this.chkClosed.Attributes.Add("onClick","return CheckClosed('" +
chkClosed.ID + "');");

It works fine. However, it will not fire a postback.

The Source shows this:

<input id="chkClosed" type="checkbox" name="chkClosed" onclick="return
CheckClosed('chkClosed');__doPostBack('chkClosed', '')"
language="javascript" />

ANy advice?



Nov 19 '05 #8

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

Similar topics

2
11645
by: Homa | last post by:
Hi, I have a Datagrid that uses as a shopping cart and have a checkbox template column in it. I can't add both OnCheckedChanged Event and onclick client script for it. I want to do two...
5
9153
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
5
3657
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
15
4713
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
2
2698
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
4
6915
by: | last post by:
I have a checkbox on a web page. When it is checked, I want a Table to appear (or disappear when the checkbox is cleared)... I was hoping to use client side code for this, so I created a short...
1
2085
by: dave | last post by:
I have a html table and mutliple rows. On each row i put an onclick event that opesn a modal window and prompts the user for some information. I want this modal window to show when the user...
10
5180
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
2241
by: sydneycan | last post by:
Hi everyone. First time I'm posting something, so far I've been able to google it out but this time no luck so far... I have a html input checkbox on my page From the javascript 'switchlayers' in...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
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,...
0
7462
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
5578
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,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.