By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,588 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,588 IT Pros & Developers. It's quick & easy.

do not want page to reload if selected index of control is 0

P: n/a
Hi I have a page that pops up a warning box if a selection is not made, see
below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the page.
Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the index
is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi I have a page that pops up a warning box if a selection is not made, see below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the page.
Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the index is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.

Nov 19 '05 #2

P: n/a
Hi thanks for the information, just wondering is this done in Java script,
and what would it look like?
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi I have a page that pops up a warning box if a selection is not made,

see
below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the page.
Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the

index
is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.


Nov 19 '05 #3

P: n/a
Yes, in JavaScript.

<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
{
window.alert("Missing Arrival Time");
---> return false; <---
}
</script>

I have not done this within a handler defined in a script block, usually
just from a function or something, but this might work for you.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Hi thanks for the information, just wondering is this done in Java script,
and what would it look like?
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi I have a page that pops up a warning box if a selection is not made,
see
below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the

page. Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the

index
is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.


Nov 19 '05 #4

P: n/a
Hi thanks for the additional information. It works!
I have 4 controls that must have valid entries before the postback takes
place,
also have a popup window for each on missing.
</script>
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
if(document.Form1.drp_dn_dtype.selectedIndex==0)
window.alert("Missing Data Type");
if(document.Form1.lstbx_dest.selectedIndex==0)
window.alert("Missing Destination");
if(document.Form1.dr_lst_event.selectedIndex==0)
window.alert("Missing Event");
if ((document.Form1.drp_dn_arriv.selectedIndex!=0) &&
(document.Form1.drp_dn_dtype.selectedIndex!=0) &&
(document.Form1.lstbx_dest.selectedIndex!=0) &&
(document.Form1.dr_lst_event.selectedIndex!=0))
{
return true;
}
else
{
return false;
}
</script>
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Yes, in JavaScript.

<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
{
window.alert("Missing Arrival Time");
---> return false; <---
}
</script>

I have not done this within a handler defined in a script block, usually
just from a function or something, but this might work for you.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Hi thanks for the information, just wondering is this done in Java script,
and what would it look like?
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
> Hi I have a page that pops up a warning box if a selection is not made, see
> below.
> <script language="javascript" event="onclick" for="btn_submit">
> if(document.Form1.drp_dn_arriv.selectedIndex==0)
> window.alert("Missing Arrival Time");
> Anyhow the btn_submit will post back to the server and reload the page. > Just wondering if anyone knows how to prevent this if the
> drp_dn_arriv.selected index = 0? This is a dropdown box and when the
index
> is 0 it means a selection has not been made. Thanks.
> --
> Paul G
> Software engineer.


Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.