Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Make Checkbox as selected after throwing Alert

    Hi,

    I'm having the following javascript code,after all the checkboxes are unslected,i'll display the alert to user saying that "Atleast one must be selected",but the checkbox is becoimng unselected,how to make check box selected after throwing this alert.

    var checkSelected = false;
    for (i = 0; i < planForm.locationOptions.length; i++) {
    if (planForm.locationOptions[i].checked) {
    checkSelected = true
    document.planForm.action='refreshPlanView.do';document.planForm.submit();
    document.getElementById("refreshing").style.display="block";
    }
    }
    if (!checkSelected) {
    alert("At least ONE Location must be selected!");
    return false;
    }
    return true;
    }

    Thanks,
    Kumar

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The alert() is not what is unchecking your checkbox element. We would need to see more code to find what is causing it.

    p.s. enclose code in the [CODE] or [PHP] tags.

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've the following code in Jsp.

    <html:form action="refreshPlanView" >
    <div id="refreshing" style="display: none; position: absolute; left: 870px; top: 150px; height: 400px; width: 300px;" >
    <h3><b><font size="4" color="#FF0000">Please wait page is REFRESHING.....</font></b></h3>
    </div>
    <table width="100%">
    <tr rowspan="6">
    <td align="center"><font size="5" color="003399">Projected Demand By Storage Type</font></td>
    </tr>
    <tr>
    <td>
    <table width="100%" border="0" align="center" >
    <tr bgcolor="000066">
    <tr />
    <tr />
    <tr bgcolor="006699">
    <td width="6%" align="center"><font size="4" color="FFFFFF">Date: </font></td>
    <td width="8%" align="center">
    <b><html:text property="inputDate" readonly="true" size = "12"/></b>
    </td>

    <td width="8%" align="center"><font size="4" color="FFFFFF">Locations:</font></td>
    <td width="40%" align="left">
    <logic:iterate id="datacenter" name="planForm" property="locationList" >
    <html:multibox property="locationOptions" onclick="showElement('refreshing')">
    <bean:write name = "datacenter" property="id"/>
    </html:multibox>
    <font color="FFFFFF"><bean:write name ="datacenter" property="location"/></font>
    </logic:iterate>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr/>
    <tr/>
    <tr>
    <td>
    <table border="1" width="100%" >
    <logic:iterate id="plan" name="viewList" property="allViewListItems">
    <tr/>
    <tr/>
    <tr/>
    <tr/>
    <tr/>
    <tr>
    <td width="100%" colspan="15" bgcolor="006699">
    &nbsp;<font size="4" color="FFFFFF">&nbsp;&nbsp;&nbsp;Location:&nbsp;<bean:write name="plan" property="location"/></font>
    </td>
    </tr>
    <tr></tr>
    <tr>
    <td width="5%" align="center" bgcolor="FF9900"><font size="3">Hardware</font></td>
    <td width="7%" align="center" bgcolor="FFCC99"><font size="3">3 Months (GB)</font></td>
    <td width="7%" align="center" bgcolor="FFCC99"><font size="3">Array Demand</font></td>
    <td width="7%" align="center" bgcolor="99FFFF"><font size="3">6 Months (GB)</font></td>
    <td width="7%" align="center" bgcolor="99FFFF"><font size="3">Array Demand</font></td>
    <td width="7%" align="center" bgcolor="FFCC99"><font size="3">9 Months (GB)</font></td>
    <td width="7%" align="center" bgcolor="FFCC99"><font size="3">Array Demand</font></td>
    <td width="7%" align="center" bgcolor="99FFFF"><font size="3">12 Months (GB)</font></td>
    <td width="7%" align="center" bgcolor="99FFFF"><font size="3">Array Demand</font></td>
    <td width="7%" align="center" bgcolor="FFCC99"><font size="3">15 Months (GB)</font></td>
    <td width="7%" align="center" bgcolor="FFCC99"><font size="3">Array Demand</font></td>


    </tr>
    <logic:iterate id="planview" name="plan" property="view">
    <bean:define id="theHardware" name="planview" property="hardware" type="java.lang.String"/>
    <bean:define id="thethreeMonthsProjection" name="planview" property="threeMonthsProjection" type="java.lang.String"/>
    <bean:define id="thethreeMonthsArrayDemand" name="planview" property="threeMonthsArrayDemand" type="java.lang.String"/>
    <bean:define id="thesixMonthsProjection" name="planview" property="sixMonthsProjection" type="java.lang.String"/>
    <bean:define id="thesixMonthsArrayDemand" name="planview" property="sixMonthsArrayDemand" type="java.lang.String"/>
    <bean:define id="thenineMonthsProjection" name="planview" property="nineMonthsProjection" type="java.lang.String"/>
    <bean:define id="thenineMonthsArrayDemand" name="planview" property="nineMonthsArrayDemand" type="java.lang.String"/>
    <bean:define id="thetwelveMonthsProjection" name="planview" property="twelveMonthsProjection" type="java.lang.String"/>
    <bean:define id="thetwelveMonthsArrayDemand" name="planview" property="twelveMonthsArrayDemand" type="java.lang.String"/>
    <bean:define id="thefifteenMonthsProjection" name="planview" property="fifteenMonthsProjection" type="java.lang.String"/>
    <bean:define id="thefifteenMonthsArrayDemand" name="planview" property="fifteenMonthsArrayDemand" type="java.lang.String"/>

    <%
    java.text.DecimalFormat df = new DecimalFormat();
    long threeMonthsProj = Long.parseLong(thethreeMonthsProjection);
    long threeMonthsArray = Long.parseLong(thethreeMonthsArrayDemand);
    long sixMonthsProj = Long.parseLong(thesixMonthsProjection);
    long sixMonthsArray = Long.parseLong(thesixMonthsArrayDemand);
    long nineMonthsProj = Long.parseLong(thenineMonthsProjection);
    long nineMonthsArray = Long.parseLong(thenineMonthsArrayDemand);
    long twelveMonthsProj = Long.parseLong(thetwelveMonthsProjection);
    long twelveMonthsArray = Long.parseLong(thetwelveMonthsArrayDemand);
    long fifteenMonthsProj = Long.parseLong(thefifteenMonthsProjection);
    long fifteenMonthsArray = Long.parseLong(thefifteenMonthsArrayDemand);
    %>
    <tr>
    <td align="center" width="5%"><font size="2"><bean:write name="planview" property="hardware"/></font></td>
    <td align="right" width="7%" bgcolor="FFCC99"><font size="2"><%=df.format(threeMonthsProj)%></font></td>
    <td align="right" width="7%" bgcolor="FFCC99"><font size="2"><%=df.format(threeMonthsArray)%></font></td>
    <td align="right" width="7%" bgcolor="99FFFF"><font size="2"><%=df.format(sixMonthsProj)%></font></td>
    <td align="right" width="7%" bgcolor="99FFFF"><font size="2"><%=df.format(sixMonthsArray)%></font></td>
    <td align="right" width="7%" bgcolor="FFCC99"><font size="2"><%=df.format(nineMonthsProj)%></font></td>
    <td align="right" width="7%" bgcolor="FFCC99"><font size="2"><%=df.format(nineMonthsArray)%></font></td>
    <td align="right" width="7%" bgcolor="99FFFF"><font size="2"><%=df.format(twelveMonthsProj)%></font></td>
    <td align="right" width="7%" bgcolor="99FFFF"><font size="2"><%=df.format(twelveMonthsArray)%></font></td>
    <td align="right" width="7%" bgcolor="FFCC99"><font size="2"><%=df.format(fifteenMonthsProj)%></font></td>
    <td align="right" width="7%" bgcolor="FFCC99"><font size="2"><%=df.format(fifteenMonthsArray)%></font></td>

    </tr>

    </logic:iterate>

    </logic:iterate>

    </table>
    </td>
    </tr>
    </table>
    </html:form>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •