Onclick checkbox

How to set checkbox value (or checked value) when onclick JavaScript event is occured.
I need to send the value of checkbox to the Action (struts - ActionForm )
I keep the allt value in the session scope and has to be changed when the checkbox status is changed.
In JSP I have this:
<%
            if (((String)session.getAttribute("allt")).equals("1")) {
  %>
       <input type="checkbox" NAME="all" value='<%= "1" %>' checked onclick="submitAllForm()">Show only the latest versions.</td>
       <% } else {
       %>
       <input type="checkbox" NAME="all" value='<%= "0" %>' onclick="submitAllForm()">Show only latest versions.</td>
       <% }
              %>       JavaScript
function submitAllTForm() {
     document.forms.allForm.submit();
}

JavaScript
function submitAllTempsForm() {
var x=document.forms.allTempsForm.alltemps1;
    alert('alltemps1  .'+ x.checked);
if  (x.checked) {
     document.forms.allTempsForm.alltemps.value= '1';
     else {
     document.forms.allTempsForm.alltemps.value= '0';
     document.forms.allTempsForm.submit();
}JSP
<html:form action="/AllTemplates.do?start=0">
<tr class="section_title" align="center" VALIGN="middle">
  <td height="30">
   <input type="hidden" name="alltemps" />
  <%
            if (((String)session.getAttribute("allt")).equals("1")) {
  %>
       <input type="checkbox" NAME="alltemps1" id="box" checked onclick="submitAllTempsForm();">Show only the latest versions.</td>
       <% } else {
       %>
       <input type="checkbox" NAME="alltemps1" id="box" onclick="submitAllTempsForm();">Show only the latest versions.</td>
       <% }
              %>       
</tr>
</html:form>   In ActionForm I have 2 properties - alltemps and alltemps1
In Java Action class (struts) - I check the value of form field and set the session variable allt. Different methods are called depands what I get from the form (checkbox).
The error is now in JavaScript:
saying that checked is a null or not an object.
What is wrong, please?

Similar Messages

  • Button control to make checkbox checked

    I have a button control, not a submit button, that when pressed, I want a checkbox to get checked. Is this possible? I set up a workflow and it will change the checkbox property to "true" or "yes", and will outline the checkbox in red,
    but will not check it. If this is not possible, can the button control be disabled after it is clicked once?

    You will need JavaScript to accomplish this. Something like
    <input type="button" onclick="CheckBox(checkboxId)" value="Check" />
    <script type="text/javascript">
    function CheckBox(checkBoxId)
    document.getelementById(checkBoxId).checked = true;
    </script>
    Nikolas Charlebois-Laprade Microsoft Certified Professional & Software Engineer http://nikcharlebois.com

  • Jsp throw numberformatexception.see my code .reply as soon as possible

    i am developed application onclick checkbox delete the record.on first field i give the href to serailno for open the update page. like this <a href="UpdateBoq.jsp?S_NO=<%=sno%>">.sno is serialno.is come from database wihen i am click on serial no it show the updatepage.jsp is not open the updatepage.jsp but it throw the exception number format.this is my code.anybody help me this my project working i am only the single persion to develop this application in jsp.please help me.as soon as possible
    <%@ page language="java" import="java.sql.*"%>
    <%@ page import="java.text.SimpleDateFormat" %>
    <%@ page import="java.util.Date" %>
    <%! int count = 0; %>
    <%! String itemcode;%>
    <%! String sns;%>
    <%! String contunit; %>
    <%! float qty; %>
    <%! float oup;%>
    <%! float oep;%>
    <%! int sno;%>
    <%! int stcode;%>
    <%! float sum=0.0f;%>
    <%! float sum1=0.0f;%>
    <jsp:useBean id="sos" class="boq.Calculation" scope="request"/>
    <%
    //String userID = String.valueOf(session.getAttribute("APP_USER_ID"));
    //String userID = String.valueOf(session.getAttribute("LOGIN_ID"));
    String strDelete = request.getParameter("btnDelete");
    String strserialno=request.getParameter("serialno1");
    String strmopno = request.getParameter("mop");
    String strjobno = request.getParameter("job");
    String strwop=request.getParameter("siten");
    String strno=request.getParameter("siteno");
    if (strDelete != null)
    String del=request.getParameter("hidcount");
    int delcount=-1;
    if (del!=null)
    System.out.println("I am in start of delete Action");
    delcount = Integer.parseInt(del);
    String strCheckBox="";
    String strHidVal="";
    for (int i=0; i<=delcount; i++)
    strCheckBox = request.getParameter("checkbox"+i);
    if(strCheckBox!=null)
    strHidVal = request.getParameter("hid"+i);
    System.out.println("country code is :"+strHidVal);
    System.out.println(del);
    Connection con=null;
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.87:1521:orcl","system","tiger");
    System.out.println(con);
    Statement st2 = con.createStatement();
    Statement st1 = con.createStatement();
    String str0="select * from BOQ where S_NO= '"+ strHidVal + "'";
    ResultSet rs = st1.executeQuery(str0);
    String str="delete from BOQ where S_NO= '"+ strHidVal + "'";
    System.out.println(strCheckBox);
    int a=st2.executeUpdate(str);
    catch(Exception e)
    %>
    <script language="JavaScript">
    alert("<%=e.getMessage()%>");
    </script>
    <%
    finally
    if(con!=null)
    con.close();
    %>
    <html>
    <head>
    <title>CRS</title>
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
    <link rel="stylesheet" href="css/ems.css" type="text/css">
    </HEAD>
    <body leftmargin=0 topmargin=2>
    <jsp:include page="Index.html" />
    <form name=form1 action="BOQVIEW.jsp" method=post>
    <table border=0 cellspacing=1 cellpadding=1 width=100% height=5>
    <tr>
    <td valign="top" height="23">
    <table width="100%" border="0" cellspacing="1" cellpadding="1">
    <tr>
    <td bgcolor='#E6E4E4' width=45 align="Center" colspan=2>
    <font color="#5d7a80" size="2">
    BOQ OF MOPS
    </font>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td valign=top>
    <table width="100%" cellpadding="1" cellspacing="1" border="0">
    <tr>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=40>S/NO</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=60>SITE NAME</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=65>SITE NUMBER</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=90>ITEM CODE/MATERIAL CODE</td>
    <td width="180" height="5" class="ReportColumnHeader" align="center"colspan=120>CONTRACT UNIT DESCRIPTION ORIGINAL</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=>QUANTITY</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=90 >ORIGINAL UNIT PRICE</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=100>ORIGINAL EXTENDED PRICE</td>
    </tr>
    </table>
    <%
    Connection con=null;
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger");
    System.out.println(con);
    Statement st = con.createStatement();
    Statement st1=con.createStatement();
    String qoq=request.getParameter("qoq");
    int one=Integer.parseInt(qoq);
    ResultSet rs = st.executeQuery("SELECT * from BOQ where SITE_CODE="+one);
    ResultSet rs1=st1.executeQuery("select SUM(O_U_P) AS oriunitprice,SUM(O_E_P) AS oriextendsprice from boq WHERE SITE_CODE="+one);
    %>
    <%
    int count=0;
    while(rs.next())
    sno=rs.getInt(1);
    stcode=rs.getInt(2);
    sns=rs.getString(3);
    itemcode=rs.getString(4);
    contunit = rs.getString(5);
    qty=rs.getFloat(6);
    oup = rs.getFloat(7);
    oep = rs.getFloat(8);
    %>
    <table border="0" cellspacing="1" cellpadding="1" width="100" >
    <tr>
    <td class="ReportCellText1" width="10" height=><input type=checkbox name="<%="checkbox"+count%>" onselect="deleterecord();"> </td>
    <td class="ReportCellText1" width="130" height="5" align="center" colspan=29><a href="UpdateBoq.jsp?S_NO=<%=sno%>"><%=sno%></a>
    </td>
    <td class="ReportCellText1" width="55" height="5" align="center" COLSPAN=60><%=sns%></td>
    <td class="ReportCellText1" width="50" height="5" align="center" COLSPAN=65><%=stcode%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=90><%=itemcode%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=120><%=contunit%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=54><%=qty%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=90><%=oup%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" colspan=100> <%=oep%></td>
    </tr>
    <tr>
    </table>
    <input type=hidden name="<%="hid"+count%>" value="<%=sno%>">
    <!--
    </tr>
    <tr>
    </tr>
    <tr>
    </tr> !-->
    <%
    count++;
    %>
    <table width="100%" cellpadding="1" cellspacing="1" border="0">
    <TR>
    <td width="60" height="5" class="ReportCellText3" align="center" colspan=></td>
    <td class="ReportCellText3" width="55" height="5" align="center" COLSPAN=></td>
    <td width="60" height="5" class="ReportCellText3" align="center" colspan=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <%
    rs1.next();
    sum=rs1.getFloat("oriunitprice");
    sum1=rs1.getFloat("oriextendsprice");
    %>
    <td width="60" height="5" class="ReportColumnHeader" align="center" colspan=>TOTLE AMOUNT</td>
    <td class="ReportCellText1" width="85" height="5" align="center" colspan=> <%=sum%></td>
    <td class="ReportCellText1" width="90" height="5" align="center" colspan=> <%=sum1%></td>
    </table>
    <TABLE>
    <input type=hidden name=hidcount value =<%=count%>>
    <input type=hidden name=serialno value=<%=itemcode%>>
    <INPUT TYPE=hidden NAME=mop VALUE=<%=contunit%> >
    <INPUT TYPE=hidden NAME=job VALUE=<%=qty%> >
    <INPUT TYPE=HIDDEN name=siten value=<%=oup%>>
    <input type=hidden name=siteno value=<%=oep%>>
    <table><tr><td>
    <input type = button value = Print size=20 onClick = "window.print();"></td>
    <td><input type = Submit value = "Delete" name="btnDelete" size = 20> </td>
    </form>
    <form action=BOQ.jsp method=post>
    <td><input type=Submit value = "Add New" size=20></td>
    </form>
    <form action=NEWPEexl.jsp method=post>
    <td><input type=Submit value = "Export to Excel" size=20></td></tr></table>
    </form>
    <%
    catch(Exception e)
    out.println(e.getMessage());
    finally
    if(con!=null)
    con.close();
    %>
    </body>
    </html>
    when i am click the serial no it show the update page is update .jsp
    this is the update code
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
    prefix="fileaccess"%>
    <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld"
    prefix="database"%>
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page language="java" import="java.sql.,java.util."%>
    <%@ page import="java.text.SimpleDateFormat" %>
    <%@ page import="java.util.Date" %>
    <%! int count = 0; %>
    <%!Connection con=null;%>
    <%!PreparedStatement ps=null;%>
    <%
    String strUpdate = request.getParameter("btnUpdate");
    String sno=request.getParameter("serialno1");
    int snoi=Integer.parseInt(request.getParameter("serialno1"));
    String sc=request.getParameter("sitenumber");
    int sci=Integer.parseInt(request.getParameter("sitenumber"));
    String sn=request.getParameter("sitename");
    String itc=request.getParameter("itemno");
    String cu=request.getParameter("contract");
    String qty=request.getParameter("quantity");
    float qtyf=Float.parseFloat(request.getParameter("quantity"));
    String oup=request.getParameter("orig");
    float oupf=Float.parseFloat(request.getParameter("orig"));
    String oep=request.getParameter("origexp");
    float oepf=Float.parseFloat(request.getParameter("origexp"));
    if (strUpdate != null)
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.87:1521:orcl","system","tiger");
    System.out.println(con);
    System.out.println("Connection Established");
    Statement st = con.createStatement();
    String str="update BOQ set SITE_CODE="sci",SITE_NAME='"sn"',ITEM_CODE='"itc"',CONTRACT_UNIT='"cu"',QTY="qtyf",O_U_P="oupf",O_E_P="oepf" where S_NO="snoi" ";
    int a=st.executeUpdate(str);
    if (a>0)
    %>
    <script type="text/javascript" >
    alert("The Record has been Updated Successfully");
    <% response.sendRedirect("BOQVIEW.jsp"); %>
    </script>
    <%
    catch(Exception e)
    String m = e.getMessage();
    %>
    <font size="1" face="Verdana" color=blue>
    "<%=m%>"</font>
    <%
    try
    if(con!=null)
    con.close();
    catch(SQLException sq)
    out.println(sq.getMessage());
    %>
    <!-- Insert the data code-->
    <HTML>
    <head>
    <title>BOQ</title>
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
    <script type="text/javascript">
    function callingdate()
    Calendar.setup({
    inputField : "f_date_b", //*
    ifFormat : "%d-%b-%Y ",
    showsTime : true,
    button : "f_trigger_b", //*
    step : 1
    function callingdate1()
    Calendar.setup({
    inputField : "f_date_b1", //*
    ifFormat : "%d-%b-%Y ",
    showsTime : true,
    button : "f_trigger_b1", //*
    step : 1
    function dating()
    var mylist=document.getElementById("effective_date")
    document.getElementById("date").value=mylist.options[mylist.selectedIndex].text
    function caps() {
    document.form1.country_code.value = document.form1.country_code.value.toUpperCase()
    document.form1.country_name.value = document.form1.country_name.value.toUpperCase()
    </script>
    </head>
    <BODY >
    <% count++;
    %>
    <form name=form1 action=UpdateBoq.jsp method=post>
    <!-- <h3 STYLE = "BACKGROUND-COLOR=blue;
    COLOR=YELLOW"
    align=center color=green>Country Information</h1> !-->
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td bgcolor='#336699' align="Center"><font color="#d2b48c" size=2>BOQ OF MOPS</font> </td>
    </tr>
    </table>
    <%
    Connection con=null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.87:1521:orcl","system","tiger");
    System.out.println(con);
    Statement st = con.createStatement();
    String se=request.getParameter("serialno1");
    //int ser=Integer.parseInt(request.getParameter("serialno1"));
    String s="SELECT * from BOQ where S_NO="Integer.parseInt(request.getParameter("serialno1"))" ";
    ResultSet rs = st.executeQuery(s);
    System.out.println(s);
    %>
    <%
    while(rs.next())
    int serialno=rs.getInt(1);
    int stcode=rs.getInt(2);
    String sname=rs.getString(3);
    String itcode=rs.getString(4);
    String conunit=rs.getString(5);
    float qtyw = rs.getFloat(6);
    float oupw=rs.getFloat(7);
    float oepw=rs.getFloat(8);
    %>
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td bgcolor='#E6E4E4' align="Center" width=100%><font color="#5d7a80" size=2>BOQ OF MOPS </font> </td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr><td >
    1)SERIAL NUMBER:</td><td><input type=text name=serialno1 value= "<%=serialno%>" size=10 onblur = "caps();">
    </td></tr>
    <tr><td >
    2)SITE NUMBER:</td><td><input type=text name=sitenumber value= "<%=stcode%>" size=10 onblur = "caps();">
    </td></tr>
    <tr><td >
    3)SITE NAME:</td><td><input type=text name=sitename value= "<%=sname%>" size=10 onblur = "caps();">
    </td></tr>
    <tr><td>
    4)ITEM CODE/MATERIAL CODE:</td><td><input type=text name=itemno value= "<%=itcode%>" size = 20 onblur = "caps();" >
    </td></tr>
    <tr><td>
    5)CONTRACT UNIT DESCRIPTION:</td><td><input type=text name=contract value= "<%=conunit%>" size = 20 onblur = "caps();" >
    </td></tr>
    <tr><td>
    6)QUANTITY:</td><td><input type="text" name="quantity" value= "<%=qtyw%>" size =40 onblur = "caps();" >
    </td></tr>
    <tr><td>
    7)ORIGNAL UNIT/PRICE:</td><td><input type=text name=orig value= "<%=oupw%>" size = 20 onblur = "caps();" >
    </td></tr>
    <tr><td>
    8)ORIGNAL EXTENDED/PRICE:</td><td><input type=text name=origexp value= "<%=oepw%>" size = 20 onblur = "caps();" >
    </td></tr>
    </TABLE>
    <%
    %>
    <center>
    <table>
    <tr><td>
    <INPUT TYPE=Submit value = Update name="btnUpdate" size=20/></td> </tr></table>
    </form>
    <form action="BOQVIEW.jsp" method = post>
    <center> <table>
    <tr><td>
    <input type="submit" value="View" size="20"></input>
    </td> </tr></table>
    </form>
    </form>
    </table>
    </center>
    <hr>
    <script type="text/javascript">
    Calendar.setup({
    inputField : "f_date_b", //*
    ifFormat : "%d-%b-%Y ",
    showsTime : false,
    button : "f_trigger_b", //*
    step : 1
    Calendar.setup({
    inputField : "f_date_b1", //*
    ifFormat : "%d-%b-%Y",
    showsTime : false,
    button : "f_trigger_b1", //*
    step : 1
    </script>
    </BODY>
    <%
    catch(Exception e)
    out.println(e.getMessage());
    finally
    try
    if(con!=null)
    con.close();
    catch(SQLException sq)
    out.println(sq.getMessage());
    %>
    </HTML>
    this my table database oracle 9i
    CREATE TABLE BOQ
    S_NO INTEGER NOT NULL,
    SITE_CODE INTEGER,
    SITE_NAME VARCHAR2(40),
    ITEM_CODE VARCHAR2(20),
    CONTRACT_UNIT VARCHAR2(60),
    QTY FLOAT(70),
    O_U_P FLOAT(70),
    O_E_P FLOAT(70)
    );</a>

    1. Use code tags, there's button that says 'Code'. Select your text and use that. I'm not going to read your code while it's unformatted like this and especially because you seem to have posted your whole darn project here; and I suspect few others will bother either.
    2. Don't paraphrase the exception; post the exact stack trace.
    3. There's usually a line number given with the exception; which line does your stack trace point to? Try to figure out what you're doing wrong there.
    4. NumberFormatException means that you're trying to parse a string that's not in the correct format. Make sure the data you're getting from the DB is correct.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • About Multiple Filters Mode Sample

    hi very thanks for the sample , I learn the
    ds.setFilterMode("or");
    Buy i also have a question.  this is my xml file
    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <row>
    <tmId>26760001</tmId>
      <Comp_Id>654321</Comp_Id>
    <Comp_name>Web Site</Comp_name>
    </row>
    <row>
    <tmId>26760002</tmId>
      <Comp_Id>123456</Comp_Id>
    <Comp_name>Adobe</Comp_name>
    </row>
    </root>
    1. I create a dataset
    var ds1 = new Spry.Data.XMLDataSet("xmldata1.xml", "/root/row", {useCache:true});
    ds1.setFilterMode("or",true);
    function ff1(ds, row, index){ return (row.Comp_Id == "654321") ? row : null; };
    function ff2(ds, row, index){ return (row.Comp_Id == "123456") ? row : null; };
    function ToggleFilter(enable, f)
    if (enable)
      ds1.addFilter(f, true);
    else
      ds1.removeFilter(f, true);
    2. I create a same dataset but use the distinctonLoad
    var ds3 = new Spry.Data.XMLDataSet("xmldata1.xml", "root/row/Comp_name", {sortOnLoad: "Comp_name", sortOrderOnLoad: "ascending", distinctOnLoad: true});
    3.It's my problem, i want use the ds3,automatic create the checkbox, and checked=true, when onclick checkbox checked=false and filter the comp_id.
    <td  valign="top" bgcolor="#FFFFFF" spry:region="ds3">
    <form action="" >
    <label spry:repeat="ds3" >
    {ds3::Comp_name}
    <input name="ff" type="checkbox" value="{ds3::Comp_name}" checked="true" onClick="ToggleFilter(this.checked,ff1);"></label>
    </form>
    </td>
    4.question two is  how can i use a refences to replace the 654321
    function ff1(ds, row, index){ return (row.Comp_Id == "654321") ? row : null; };
    function ff1(ds, row, index,number){ return (row.Comp_Id ==number) ? row : null; };

    hi very thanks for the sample , I learn the
    ds.setFilterMode("or");
    Buy i also have a question.  this is my xml file
    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <row>
    <tmId>26760001</tmId>
      <Comp_Id>654321</Comp_Id>
    <Comp_name>Web Site</Comp_name>
    </row>
    <row>
    <tmId>26760002</tmId>
      <Comp_Id>123456</Comp_Id>
    <Comp_name>Adobe</Comp_name>
    </row>
    </root>
    1. I create a dataset
    var ds1 = new Spry.Data.XMLDataSet("xmldata1.xml", "/root/row", {useCache:true});
    ds1.setFilterMode("or",true);
    function ff1(ds, row, index){ return (row.Comp_Id == "654321") ? row : null; };
    function ff2(ds, row, index){ return (row.Comp_Id == "123456") ? row : null; };
    function ToggleFilter(enable, f)
    if (enable)
      ds1.addFilter(f, true);
    else
      ds1.removeFilter(f, true);
    2. I create a same dataset but use the distinctonLoad
    var ds3 = new Spry.Data.XMLDataSet("xmldata1.xml", "root/row/Comp_name", {sortOnLoad: "Comp_name", sortOrderOnLoad: "ascending", distinctOnLoad: true});
    3.It's my problem, i want use the ds3,automatic create the checkbox, and checked=true, when onclick checkbox checked=false and filter the comp_id.
    <td  valign="top" bgcolor="#FFFFFF" spry:region="ds3">
    <form action="" >
    <label spry:repeat="ds3" >
    {ds3::Comp_name}
    <input name="ff" type="checkbox" value="{ds3::Comp_name}" checked="true" onClick="ToggleFilter(this.checked,ff1);"></label>
    </form>
    </td>
    4.question two is  how can i use a refences to replace the 654321
    function ff1(ds, row, index){ return (row.Comp_Id == "654321") ? row : null; };
    function ff1(ds, row, index,number){ return (row.Comp_Id ==number) ? row : null; };

  • How to invoke a Servlet on onClick event of CheckBox ?

    Hi,
    Can anybody provide me with the code - how to invoke a Servlet & then pass all form variables to the Servlet on onClick Event of CheckBox in a JSP Page.
    I guess it is possible with Javascript but i need the code...
    Pls Help !
    Thanx.

    <html>
    <head>
    <script language="JavaScript">
    <!--
    function submitMyForm(){      
    document.myform.submit();
    //-->
    </script>
    </head>
    <body>
    <form name="myform" method="POST" action="http://mywebserver/servlet/myServlet" target=_top>
    <input type="checkbox" name="mycheckbox" OnClick = "javascript:submitMyForm()">
    </form>
    </body>
    </html>
    Hope this helps...

  • 4.2 - Checkbox : When onClick registered for, MRU not firing (demo incl)

    *** Hopefully this isn't a rehash, I've searched around but haven't found information on it. ***
    I have a wizard created tabular report with a Checkbox (Y/NULL) column. The wizard also created the MRU and MRD.
    In the page header, I've added the following Javascript function:
    function testme(pThis){}
    In the column attributes for my "Simple Checkbox", I added the follow to "Element Attributes":
    onClick="testme(this);"
    With this in place, when I click/unclick the checkbox and submit for a save using the MDU, the changed state of the checkbox is not saved to the database. Also, any new records (via new row) are added with a NULL for the checkbox field regardless of what is selected during creation.
    If I change "Element Attributes" to:
    onChange="testme(this);"
    Then the MDU works just fine. Only reason I'm worried about this is that I understand onChange can be problematic on certain IE versions.
    Thanks,
    Scott

    Howdy Howard (and others) -
    I was hoping someone would have an answer without generating an example, but I hi-jacked the demo and came up with one:
    http://apex.oracle.com/pls/apex/f?p=70849:9:16222360984434:::::
    Workspace: DenverScott
    UserName: Test_User
    P/W: Test123
    Page: 9
    Recreate Problem: Change the checkbox value of an item under OnChange and OnClick and press "Submit", only OnChange items actually change.
    On this report, the two columns "OnChange" and "OnClick" are the focus. They are both simple check boxes and basically have the same settings. They both call an empty javascript function "test_me(this)" when clicked. Difference is, the MRU works for the "OnChange" column, updates are applied. You can change the "Onclick" column and submit all you want and it does nothing.
    If you remove the event for OnClick="test_me(this);" from the "OnClick" column, the submit/updates work just fine.
    (If anyone changes the demo, please return to prior state for others to examine)
    Thanks,
    Scott

  • Checkbox and javascript onClick

    I have defined an sql region with the following query:
    SELECT HTMLDB_ITEM.CHECKBOX(1,serviceid) " ",
    servicedescription
    FROM service
    where coid = :P1_COID
    ORDER BY 2
    Although I read a few threads and Howtos about Javascript I didn't achieve my goal to redirect (submit) the page to itself everytime the checkbox is changed. I tried to manage this by setting
    onClick="javascript:doSubmit('Submitted');"
    in the element attribute of the serviceid column but with no success.
    Besides this I would like to analyze which checkbox (service) is checked. According to the selected services different regions should be shown/hidden on the page. May be someone could point me to the right direction.
    Thanks Tobias

    I solved it by myself...
    Tobias

  • Another Javascript issue (CheckBox onClick event)

    Hello All,
    I am using NWDS04s Adobe Designer 7.1.
    I created a IF with a TextField on it and a CheckBox. What i would like to do is, when the checkbox is checked, the TextField should disappear (TextField1.Presence = "hidden").
    I wrote this script in the OnClick event of the Checkbox:
    if (CheckBox1.rawValue == "1") {
                TextField1.presence = "hidden";
    }else {
                 TextField1.presence = "visible";
    When i deploy my WD you could guess, it's not working ;-((
    Is there something i am doing wrong??
    When i place this code in the Initialize event of the CheckBox and change the If statement to CheckBox1.rawValue == "0" it works as expected.
    Hope somebody can help me or try it on there machines. Maybe it's a bug.
    Thx in advance.
    Kind Regards,
    Maarten

    Hello Maarten,
    Please have a look at method <a href="https://media.sdn.sap.com/javadocs/NW04s/SPS7/wd/com/sap/tc/webdynpro/clientserver/adobe/pdfdocument/api/IWDPDFDocumentInteractiveFormContext.html#setDynamic(boolean)">setDynamic</a> (interface IWDPDFDocumentInteractiveFormContext).
    Regards,
    Philipp

  • ScriptUI Checkbox onClick fires differently in CS5 vs CS3?

    I'm developing an application consisting of a ScriptUI interface and a custom InDesign template. The ScriptUI interface contains a few checkboxes, with onClick event handlers assigned to read their value and store them to a preferences variable whenever they change. This all works perfectly in InDesign CS3 which was my primary development environment.
    Now I need to get this application compatible with InDesign CS5, but the checkboxes seem to consistently be returning the wrong value. No matter whether my event handler reads this.value, event.target.value or a direct reference to the checkbox, the returned value is the opposite of the expected. If I use the direct reference to read the value from elsewhere though, the returned value is correct! It almost seems like in CS5 the onClick event handler is fired before the value is changed, while in CS3 it is fired after the value is changed. Just tried CS4 and it seems to behave the same way as CS5.
    Did they actually change the checkboxes to behave this way (which makes no sense to me) or am I doing something wrong? Is there any way to get the old behavior back, or is the only solution to manually invert the value if the script detects CS4 or later as the runtime?

    Mayhem SWE wrote:
     I wonder how the execution order is in a web browser. The only valid reason I can come up with to justify the CS4/5 change would be if this is how a web browser would behave (perhaps in order to give you an opportunity to cancel the event before the value is changed?), but it is still quite confusing and illogical IMHO...
    I totally agree with you. The reason behind this —I think— is that the ScriptUI event model has been modified in CS4 in order to enhance the compliance with the DOM Level 3 Events Specification — http://www.w3.org/TR/DOM-Level-3-Events — which states that the click event must be cancelable. Thus you probably can use myClickEvent.preventDefault() in CS4/CS5 while this probably has no effect in CS3 (not tested). I suppose that the checkbox value should be actually changed if and only if the event is completed and not canceled. That makes sense, but the counterpart is that there is no more equivalence between using the onClick handler and a 'pure' click event listener: myWidget.addEventListener(...)
    On this subject, the specification says that using the shortcut myWidget.onEvent = myFunction to register an 'event listener' depends on the host language: "Because the details of this are often language-specific, this type of event listener registration is not defined in this specification, but in general, any event type may be used as an attribute in this way by adding the prefix on- to the event type name, and events so dispatched should behave consistently with the event registration and propagation defined in this specification, with the same interfaces, properties, and methods." —DOM Level3 Events Specification, 4.3 "Interface EventTarget", note 2.
    Of course, the easiest approach is to use myCheckbox.onClick = ... since the handler is called once the value has been updated, whatever the version of ScriptUI. But I don't believe it's a good practice if you're working on a complex project —especially a library!— because the onClick handler can be easily rewritten by the client code, and because you may need to deal with event propagation/cancellation at a deeper level. For my part I always use addEventListener(...) and removeEventListener(...) in my library code, although it implies that I fit my implementation to the ScriptUI version. (In CS3, reversing the checkbox value, etc.) That way the client code cannot pollute the basic behavior of my widgets.
    Hope that helps,
    @+
    Marc

  • Checkbox onClick table updates

    Hello,
    Ok, I'm struggling here. I have a list. The first item is a checkbox, I can check/unckeck the box without any trouble. What I can NOT do is update the table based on when the box is unchecked. I've created a Tabular Form and want to update a column on the record being reported on this form based on weather the box is checked or unchecked.
    If the box is currently checked, based on the data in the table, and the user un-checks the box, I need to update the value in the table. Since Oracle only returns checked items, that won't work. I don't want to update the entire table every time a user unchecks record.
    I'm sure it has to do with the onClick procedure, I just can NOT seem to get this to work.
    What I need is: If the box was not originally checked but the user clicks the checkbox so that it is checked then update the record with this primary-key-value marking the yes-no column with a 'Y'. If the box was originally checked and the user unchecks the box, mark it with a 'N'.
    Please help.
    Thanks,
    Don.

    Don:
    Make these modifications.
    For the query ,modify the checkbox item's value to be a concatenated string of
    EMP_ID.<Team_Member_Status>.<team_member>
    select apex_item.checkbox(1,EMP_ID||'.'||decode(team_member,'1','Y.Y' ,'N.N')
    ,decode(team_member,'1','CHECKED' ,Null) || ' onClick=setVal(this)') "On Team",
    apex_item.text(2,Fullname)
    from employees;Add the Javascript below to your page
    <script>
    function setVal(cb) {
    // split the value of the chekbox
    vals=cb.value.split('.');
    //set third element of the chekbox value string to indicate users new selection
    if (cb.checked)
       vals[2]='Y'   
    else
       vals[2]='N';
    // put the value of checkbox together
    cb.value=vals[0] + '.' + vals[1] + '.' + vals[2]
    function setAll() {
    cbs=document.forms[0].f01;
    // set all checkboxes so that each can be refereced in the g_f01 array
    for (i=0;i<cbs.length;i++){
        cbs.checked=true;
    // submit the form
    doSubmit('SUBMIT')
    </script>
    Set the SUBMIT button of your page to re-direct to the URL
      javascript:setAll
    Now, your after submit process can access each checkbox (via the g-f01 array)
    and the value of the checkbox will be a concatenated string formatted as
    <emp_id>.<original value of team member>.<new value of team member>
    You can now split the concatenated string into its components. Comparing the old and new settings of the 'team member' components will let you decide whether the record corresponding to the 'empid' needs to be updated or not.
    Hope this works for you.
    Varad                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need checkbox onclick somehow to run SQL query

    Hello all,
    Now, I know directly I cannot do this with a javascript function.  What I need to do is with a checkbox onclick
    set a hidden field to the type of the data that is selected by the checkbox.  So, if I select the name of a person,
    the onclick method needs to let the hidden field know we have a "person" entity type. I need this type because
    when I do my true submit, that form field when read will denote what next page I need to bring up in a new tab.
    The question I have is ok, I can attempt to do this a couple of ways, following:
    1)  Come up with an AJAX call that will run a function on the server.  What I do worry about is
    submitting the page and ending up losing boxes that were checked.  I also don't want a long
    form submittal after every click.
    OR
    2)  Forget the onclick method, create a blank .cfm form, then use that form to run the query for the
    types of data, and then call the page to be displayed?  Again, I'm new, so I don't know if this could
    be weird in how the page comes up for display?
    Thanks in advance!!!!!

    Hey Dan,
    Yep, I'm very new at using CF, so I pretty much stink at it compared to you all.  However, I fixed my one problem in that I don't need
    to do anything with SQL queries with onclick.  I combined a bunch of forms into one and process stuff on that page.  Matter of fact,
    I needed to do that.
    However, what I do have a problem with is one last part of my keeping checkbox values when paging.  I can do almost everything,
    meaning, keep track of checkbox values when checked by having a list of those values in session.  I can check the boxes when
    I go back to the page with a simple <CFIF> block when the checkboxes are created for the page.
    The issue I have now is how I can delete a value from the session list when a checkbox is unchecked.  I don't know if I should
    keep track of the exact page number, or whatnot.  All I have now is a list of node ids.
    Any ideas?
    Thanks,
    Ed

  • CHECKBOX submission onclick

    Hi. I have a small question to ask:
    I am using struts with the Jsp page, and I am using the struts' HTML library.
    So, having the following code:
    <html:checkbox properties="SomeBeab.someFfield" onclick=SOMETHING styleClass="btn"/>
    Instead of SOMETHING at the onclick attribute I have a javascript that submits the form. However, I ran into this trouble.
    When the check box is not checked initially, the form gets subitted fine, the check box gets checked and everything that has to happen happens.
    However, when the check box is initially checked and want to uncheck it, and on this unchecking I want the form to get submitted with the knowledge that a checkbox was cleared, THIS DOESN'T HAPPEN.
    I found out that this is a common web problem - not just a JSP or struts'. I also heard that there is some way to mitigate this by using some kind form's reset() method of the Struts API, or something .. I am not clear on what it is and how to go about this. I'll greatly appreciate the help in this matter.

    Well ... I didn't know about that .. thanks.
    But .. that wasn't the sourse of the issue. I do have to put some programmatic validation it ....

  • HTTP post when a checkbox has been ticked (onclick event)?

    Is there a way to do a http post for every onclick event on check boxes?
    I need to post some data with parameters to an API or something that can be sent a HTTP post.

    OK, just wanted to make sure. Have a look at the Net.HTTP object. It has a single method, request, which allows you to exeute an HTTP request such as GET, POST, etc. But read the documentation well, there are some serious limitations on this method. The main one being that is has to be executed from a folder-level script.
    Alternatively, you can use the app.launchURL() method to open a web-page. The user will have to allow it, though.

  • Unable to get checkbox working in Apex 3.2.1.00.10

    We recently upgraded our production application running on apex to Apex 3.2.1.00.10. Everything works, except for the query that generates the check-box. This used to do so in the previous version 3, but does not work anymore, the code is the same...Any help is appreciated.
    (SELECT app_user, app_session, hier_username, NULL, NULL, NULL, NULL,
    ' ', HTMLDB_ITEM.checkbox (2, 1, 'onClick = "WssMasterCheck()"')
    FROM wss_uform_data
    GROUP BY app_user, app_session, hier_username)
    UNION ALL
    (SELECT app_user, app_session, hier_username,
    HTMLDB_ITEM.hidden (11, hier_code_combination),
    HTMLDB_ITEM.hidden (12, hier_parent_level_number),
    HTMLDB_ITEM.hidden (13, hier_level_type), hier_level_number,
    hier_level_name,
    HTMLDB_ITEM.checkbox (3,
    hier_level_number,
    DECODE (checked, '0', NULL, 'CHECKED')
    ) -- this is one that is not working, and does not show as checked.
    FROM wss_uform_data
    WHERE hier_level_type =
    wss_preferences_pkg.get_default_value ('WHOLESALER_LEVEL_TYPE'));

    Not sure what happened, as I had tried this before too, but I did do the change below and was trying to debug the issue on my own and trying some options, and all of a sudden it started working...The only change that I did is below:
    (SELECT app_user, app_session, hier_username, NULL, NULL, NULL, NULL,
    ' ', HTMLDB_ITEM.checkbox (2, 1, 'onClick = "WssMasterCheck()"')
    FROM wss_uform_data
    GROUP BY app_user, app_session, hier_username)
    UNION ALL
    (SELECT app_user, app_session, hier_username,
    HTMLDB_ITEM.hidden (11, hier_code_combination),
    HTMLDB_ITEM.hidden (12, hier_parent_level_number),
    HTMLDB_ITEM.hidden (13, hier_level_type), hier_level_number,
    hier_level_name,
    HTMLDB_ITEM.checkbox (3,
    hier_level_number,
    DECODE (checked, '0', 'UNCHECKED', 'CHECKED') -- replaced NULL with 'UNCHECKED' is the change I made
    FROM wss_uform_data
    WHERE hier_level_type =
    wss_preferences_pkg.get_default_value ('WHOLESALER_LEVEL_TYPE'));

  • Check all checkboxes in a column of a tabular form

    Hi,
    I think this can be useful for some people.. I have a tabular form with several columns containing checkboxes. I wanted to be able to check or uncheck a whole column. The problem is that I didn't find a function to do this. So I modified (and renamed) the $f_CheckFirstColumn(pNd) function.
    In "edit page > JavaScript Function and Global Variable Declaration", add this :
    function $f_CheckNthColumn(c,n){
         var e=$x_UpTill(c,"TABLE");
         for(var d=0,a=e.rows.length;d<a;d++){
              var b=$x_FormItems(e.rows[d],"CHECKBOX")[n];
              if(b){
                   if(b.checked != c.checked) {
                        b.click();
         return;
    }EDIT : The status of the checkboxes checked with the function below is not passed when submitting the form (it is passed when clicking on every checkbox). This is why I had to use the click() function (so that onClick is triggered).
    --function $f_CheckNthColumn(c,n){
         var e=$x_UpTill(c,"TABLE");
         var f=[];
         for(var d=0,a=e.rows.length;d<a;d++){
              var b=$x_FormItems(e.rows[d],"CHECKBOX")[n];
              if(b){
                   f[f.length]=b;
         $f_CheckAll(false,c.checked,f);
         return f;
    And in the report column header :
    <input type="checkbox" onClick="$f_CheckNthColumn(this, NUMBER);" />NUMBER being the column number (1st column containing checkboxes = 0, 2nd column containing checkboxes = 1, etc.)
    I'm using APEX 4.1.1.00.23, so I can not guarantee It'll work on other versions.
    Hope this can help !
    Edited by: ben0123 on Jul 13, 2012 12:12 AM
    Edited by: ben0123 on Jul 13, 2012 1:17 AM

    Glad it helped :)
    If you have only one checkbox that is conditional, you could change the $f_CheckNthColumn function by adding this kind of condition :
    if ($x_FormItems(e.rows[d],"CHECKBOX").length == max_number_of_checkboxes || n < position_of_conditional_checkbox) toggle checkbox(n); // all the checkboxes are displayed, or the nth checkbox is before the conditional checkbox
    else // one (or more?) checkbox is missing
      if (n == position_of_conditional_checkbox) do nothing;
      else toggle checkbox(n-1);

Maybe you are looking for

  • Couldn't install Flash Player 10.2 or AIR 2.6 on Galaxy Ace S5830 2.2.1 Froyo

    Just got a brand new Samsung Galaxy Ace S5830 mobile, and couldn't install Flash Player 10.2 nor AIR 2.6 I doesn't list in the mobile Market app, as well as, if I try to install from market.android.com, its says "This item is not compatible with your

  • Default attribute in XSD is not working..???

    i have created one BPEL process which will read xml file for which i have created xsd file. In this xsd i have specified some elements Which are the parts of ComplexType with default attribute. But when i pass empty data for thos elements then it is

  • Attach document while Goods receipt in MIGO

    Hi, Can I attach a word or a pdf document while posting Goods receipt via MIGO. In 'Service for Object' the option  store document is not possible. It is grey out. Do I need to do some settings to get this option so as to upload a file while posting

  • Assign document type to plant?

    Hi! Document types are assign to sales areas but i need to assign one specific document type to only a few plants of this sales area. ¿How could i do this? Regards. Eduardo

  • Flash Player Freezing

    Hi i hope someone out there has had this same issue and has a solution as i am out of ideas the problem i am experiencing is with ie8 and firefox versions of flash player everything has been working great for some time now until the last couple of da