Solved

RadioButton action to be cancled... asp.net c#, javascript

Posted on 2014-07-20
8
288 Views
Last Modified: 2014-07-20
The message in this code fires up ok:
       function handleRollup(myRadio) {
           alert('Monthly option not available at this point.');
           myRadio.value = 2;   <-- this part doesn't work
    }

from:

<asp:Panel ID="optRollup" Class="optRollup" runat="server" OnChange="javascript:updateRollup();" >
<asp:RadioButton ID="RadioButton1" name="Rollup" Text="Monthly" runat="server"  onclick="javascript:handleRollup(this);" value="1" GroupName="Rollup" />&nbsp

<asp:RadioButton ID="RadioButton2"  name="Rollup" Text="YTD" Checked="true" runat="server"  onclick="javascript:handleRollup(this);" value="2"  GroupName="Rollup"/>&nbsp&nbsp
</asp:Panel>

Open in new window


As you can see, there are two options here:

o Monthly
o YTD    <-- default selection

Question 1: How can this function could be modified to keep YTD option selected.
Question 2: Are there options to customize the alert(''); box (title of the box or add icons similar to vbInformatio or vbWarning)?

Thank you.
0
Comment
Question by:Mike Eghtebas
  • 4
  • 4
8 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40207682
1: How can this function could be modified to keep YTD option selected.
Don't use the same GroupName

Question 2: Are there options to customize the alert(''); box (title of the box or add icons similar to vbInformatio or vbWarning)?
No, you can't customize it, you need to use a Javascript plugin
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40207742
leakim971,

re> Don't use the same GroupName

By definition, radio button has to have the same group name. I renamed them as GroupName="Rollup1" and GroupName="Rollup2", the radio buttons stopped working.

I suppose having name="Rollup1" and name="Rollup2" and somehow revising :

myRadio.value = 2;   <-- this part doesn't work

based on name property may work.

Question: Could you do this part if you think it could be the solution?

Thank you,

Mike
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40207747
the radio buttons stopped working

What does that mean?
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40207760
re:> What does that mean?

Upon start, bey default, upon launching the page, I get:

o Monthly
o YTD    <-- default selection

Now, when I click on Monthly option, I get both of them selected. Unlike a checkbox group, this is not acceptable in radiobutton group. Now I get:

o Monthly   <--  shows selected
o YTD    <-- also shows selected

Any additional click on either of the two options, does't do a thing. They both  remain selected.

Thank you,

Mike
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 82

Expert Comment

by:leakim971
ID: 40207766
you want to set value=2 but not with YTD checked?
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40207772
I want to exclude Monthly for now.

I do not want to disable the option group because it is a good idea to give them a chance to select Monthly option and read my message. But now, after the message, it has to go back to YTD.

I hope this could help.

Mike
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40207781
yeah else that just made it not logic.

document.getElementById("<%= optRollup.ClientID %>").getElementsByTagName("input")[1].checked = true;

Open in new window


or maybe just :

document.getElementById("<%= RadioButton2.ClientID %>").checked = true;

Open in new window

0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 40207816
Thank you very much.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Safari SVG Image Problem 1 19
bulid json format 3 19
Different Delete Messages 7 12
How can I do a Select All on this page? 8 10
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now