Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   How to make it only one single radio button's things display when page load? (http://www.go4expert.com/community/single-radio-buttons-display-page-load-t25772/)

gsting_88 13May2011 08:49

How to make it only one single radio button's things display when page load?
 
2 Attachment(s)
Here is my coding..

Code:

<jsp:useBean id="chequeStopBean" scope="session" class="my.com.infopro.ibank.ui.bean.ChequeStopBean"/>
<jsp:useBean id="labelBean" scope="session" class="my.com.infopro.ibank.ui.bean.LabelBean"/>
<jsp:useBean id="lang" scope="session" class="my.com.infopro.ibank.ui.bean.LanguageBean" />

<%@ page language="java" import = "java.util.*" errorPage="" %>
<%@ page import="my.com.infopro.ibank.dto.ChequeDTO"%> 
<%
    request.getSession(true);
    String contextPath = request.getContextPath();
    chequeStopBean.queryAccList();
    //RequestDispatcher dispatcher = null;
 
%>
<html>

<head>
<title><%=labelBean.getLabel("STOP_CHEQUE")%></title>
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta HTTP-EQUIV="Expires" content="-1">
<jsp:include page="/ScriptHeader.jsp"/>
<script language="javascript">

 
function validateAndSubmit() {
   

    var msg1 = "<%=labelBean.getLabel("MSG_REQUIRED_FIELD")%>";
    var msg2 = "<%=labelBean.getLabel("MSG_CANNOT_CONTAIN_CHARACTER")%>";
    var msg3 = "<%=labelBean.getLabel("MSG_IN_THE_FIELD")%>";
    var msg4 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER")%>";
    var msg5 = "<%=labelBean.getLabel("WITH")%>";
    var msg6 = "<%=labelBean.getLabel("TO")%>";
    var msg7 = "<%=labelBean.getLabel("MSG_CHARACTER")%>";
    var msg8 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_VALID_NUMBER")%>";
    var msg9 = "<%=labelBean.getLabel("MSG_REQUIRED_FIELD")%>";
    var msg10 = "<%=labelBean.getLabel("MSG_WITH_EXACTLY")%>";
    var msg11 = "<%=labelBean.getLabel("MSG_WITH_VALID_DATE")%>";
    var msg12 = "<%=labelBean.getLabel("MSG_EXAMPLE_DATE")%>";
    var msgNum11 = "<%=labelBean.getLabel("MSG_WITH_A_MINIMUM_VALUE_OF")%>";
    var msgNum12 = "<%=labelBean.getLabel("MSG_WITH_A_MAX_VALUE_OF")%>";
    var msgNum13 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_ROUND_INETEGER")%>";
    var msgNum14 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_AT_MOST")%>";
    var msgNum15 = "<%=labelBean.getLabel("MSG_DECIMAL_PLACES")%>";
    var msgEnter = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_VALID")%>";
    var errorMsg = "<%=labelBean.getLabel("MSG_LOWECASE_ALPHABET_ALLOWED")%>"


    var radioButtons = document.getElementsByName("radio");
          for (var x = 0; x < radioButtons.length; x ++) {
           
            if (radioButtons[x].checked) {
                if(radioButtons[x].value=="1")
                {
                                             
                    if (! validateTextEntry(form.chqNum, "<%=labelBean.getLabel("CHQNUM")%>" + " ", true,11,11, msg1, msg2, msg3,
                            msg4, msg5, msg6, msg7, msg10) )
                        return false;
                   
                    if (! validateAlphabet(form.chqNum, "" + " ",1, msg2,"" ))
                        return false;   
                     
             
                }
                else if(radioButtons[x].value=="2")
                {

                    if (! validateTextEntry(form.chqNumFrom, "<%=labelBean.getLabel("CHQNUMFROM")%>" + " ", true,11,11, msg1, msg2, msg3,
                            msg4, msg5, msg6, msg7, msg10) )
                        return false;

                    if (! validateTextEntry(form.chqNumTo, "<%=labelBean.getLabel("CHQNUMTO")%>" + " ", true,11,11, msg1, msg2, msg3,
                            msg4, msg5, msg6, msg7, msg10) )
                        return false;

                    if (! validateAlphabet(form.chqNumFrom, "" + " ",1, msg2,"" ))
                        return false;   

                    if (! validateAlphabet(form.chqNumTo, "" + " ",1, msg2,"" ))
                        return false;                                         
                   
                    if(form.chqNumFrom.value == form.chqNumTo.value){
                        alert("<%=labelBean.getLabel("MSG_CANNOT_SAME")%>");   
                        return false;
                    }
                         
                }
              }
          }   
                             
        return true;
    }



   
function show(id)

    if (document.getElementById(id).style.display == 'none') 
    {
         
          document.getElementById(id).style.display = 'block';                         
    }
     

//--> 
 
<!-- 
function hide(id) 

          document.getElementById(id).style.display = 'none'; 
}

</script>
</head>

<body onload="show('single')">
<form name="form" method="POST" action="<%=contextPath%>/ChequeStopServlet?tranx=confirm" dir="<%=lang.getDir()%>" >

  <table width="500" align="center">
    <tr>
      <td align="left" colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" colspan="3" class="mainHeader"><%=labelBean.getLabel("STOP_CHEQUE")%></td>
    </tr>
    <tr>
    <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3" class="subHeader"><%=labelBean.getLabel("CHQ_DETAIL") %></td>
    </tr>
   
    <tr>
      <td colspan="3"><div align="center">
          <p class="statusError">
            <%if(request.getParameter("error") != null) out.println(labelBean.getLabel(request.getParameter("error"))); else out.println("");%>
          </p>
        </div></td>
    </tr>
   
    </table><br />
    <table width="500" align="center">
    <tr>
      <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("ACC_NUMBER")%></td>
      <td width="10"  class="lbl">:</td>
      <td width="305" align="left"> 
      <select size="1" name="accNum">
     
    <%
              for (Iterator iter = chequeStopBean.getAccList().iterator(); iter.hasNext();) {
                  ChequeDTO chqDto = (ChequeDTO)iter.next();   
             
      %>
    <option value="<%=chqDto.getAccNum()%>"><%=chqDto.getAccNum()%></option>
      <%  } %>
      </select>
      </td>
    </tr>
    <tr>       
        <td align="right">
            <input type="radio" class="radioStyle"  name="radio" value="1"  onfocus="show('single');hide('multiple');hide('multiple1');return true;" checked="checked" >
            <%=labelBean.getLabel("STOP_SINGLE")%>
        </td>
        <td>&nbsp;</td>
        <td>
            <input type="radio" class="radioStyle"  name="radio" value="2"  onfocus="hide('single');show('multiple');show('multiple1');return true;">
            <%=labelBean.getLabel("STOP_MULTIPLE")%>
        </td>
    </tr>
   
    <tr id="single">
      <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("CHEQUE_NUMBER")%></td>
      <td  class="lbl"width="10">:</td>
      <td colspan="2" align="left">
      <input name="chqNum" type="text" size="15">
      </td></tr>
           
    <tr id="multiple" style="display: 'none'">
      <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("FROM_CHEQUE_NUMBER")%></td>
      <td  class="lbl"width="10">:</td>
      <td colspan="2" align="left">
        <input name="chqNumFrom" type="text" size="15">
      </td></tr>
     
      <tr id="multiple1" style="display: 'none'">
      <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("TO_CHEQUE_NUMBER")%></td>
      <td  class="lbl"width="10">:</td>
      <td colspan="2" align="left">   
      <input name="chqNumTo" type="text" size="15">
      </td></tr>
           
     
    <tr>     
      <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("REASON")%></td>
      <td  class="lbl" width="10" >:</td>
      <td colspan="2">
      <select name="reason">
      <option value="Lost"><%=labelBean.getLabel("LOST")%></option>
      <option value="Stolen"><%=labelBean.getLabel("STOLEN")%></option>
      <option value="Payment Cancellation"><%=labelBean.getLabel("PAYMENT_CANCELLATION")%></option>
      <option value="Others"><%=labelBean.getLabel("OTHERS")%></option>     
      </select>
      </td>
     
    </tr>
       
    <br/>
        <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3" align="center">
      <input  class="button" type="submit" value="Next" onClick="return validateAndSubmit();" >     
      </td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"  align="left" class="footer"><%=labelBean.getLabel("NOTE")%>
      </td>
    </tr>
    <tr><td colspan="3" class="footer">
    <ul>
        <li><%=labelBean.getLabel("THE_ASTERISK")%></li>
    </ul>
    </td>
    </tr>
   
  </table>
 

<jsp:include page="/Footer.jsp" />
 </form>
</body>
</html>

The hightlight code got problem?
or it can not use onload method to do?

Refer to attached image !!

Thanks.

gsting_88 13May2011 09:35

Re: How to make it only one single radio button's things display when page load?
 
I have found solution..:pleased:

<body onload="hide('multiple');hide('multiple1')">

Thanks!


All times are GMT +5.5. The time now is 15:25.