Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

VB.net, VS2010
i have 3 checkboxes, if the user checks the box it should ask for a confirmation in a msgbox. if OK is clicked then it should run the codebehing, if CANCEL is clicked then it should cancel the operation and refresh the page so that the wrongly checked box would retain its original state.

please help on this

thanks
Joe
Posted

1 solution

Hi,

try this

JavaScript
function f2(tid) {
        if (confirm("Are you Sure?")) {
          //do your code
        }
        else {
            document.getElementById(tid).checked = false;
        }


And design

HTML
<table width="50%" align="center" id="dt1">
           <tr> <td>   <input type="checkbox" id="ch1" onclick="f2(this.id)"  />
               </td>
           </tr>
           <tr>
               <td>
                   <input type="checkbox" id="ch2" onclick="f2(this.id)" />
               </td>
           </tr>
           <tr>
               <td>
                   <input type="checkbox" onclick="f2(this.id)"  />
               </td>
           </tr>
           <tr>
               <td>
                   <input type="checkbox" />
               </td>
           </tr>
         </table>


All the Best
 
Share this answer
 
Comments
joe_j 18-Oct-11 2:27am    
THanks for that but it doesnt work it throws an error
i tried
else {document.getElementById('<%=cb_ibinv.ClientID %>').checked = false;}
but they are all giving error
and for the checkbox i tried onclientclick="return f2()" still error
Muralikrishna8811 18-Oct-11 4:32am    
there is no onclientclick event for checkbox
Muralikrishna8811 18-Oct-11 4:38am    
letme try another way
Muralikrishna8811 18-Oct-11 4:43am    
K fine

and you've to follow some other way for your requirement.
means using jquery you can post data to server on confirm yes.

think about this.

joe_j 18-Oct-11 4:57am    
mm not so sure on how to do this actually
if you could help me on this it would be great.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900