<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Date"%>
<%@ taglib uri="/WEB-INF/ajaxtags.tld" prefix="ajax" %>
<%@ taglib uri="/WEB-INF/struts/struts-html.tld" prefix="html" %>

<html>
<head>
    <title>AJAX Tags (C) 2005 Jenkov Development</title>
    <link rel="stylesheet" href="/prizetagsdemo/stylesheet.css" type="text/css">
</head>
<body>

<script type="text/javascript" src="jenkov_ajaxScript.js"></script>

<h2>Prize Tags - AJAX Tags Demo - Form Submit</h2>

<p>
    This JSP page demonstrates the JSP AJAX Tags of the JSP Prize Tags.
    There are several demos. Each demo demonstrates how an HTML form
    can be submitted, and the result displayed inside a table cell,
    without reloading the entire page.
</p>

<br/><br/>





<!-- DEMO 1 -->

<table class="tableBordered" width="300">
    <tr><td>Ajax Form Submit Example 1 - JSP Ajax Tags</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>
        <ajax:form targetElement="target">
            <form action="ajaxFormReceiver.jsp"  onsubmit="">
            <input type="text"   name="param1" value="111"/><br/>
            <input type="text"   name="param2" value="222"/><br/>
            <input name="submit1" type="submit" value="Submit1 - Button not submitted"/><br/>
            <ajax:submit><input name="submit2" type="submit" value="Submit2 - Button Recognized"/></ajax:submit><br/>
            <ajax:submit><input name="submit3"   type="submit" value="Submit3 - Button Recongnized" /></ajax:submit><br/>
            </form>
        </ajax:form>
    </td></tr>

</table>

<br/><br/>
<table class="tableBordered" width="300">
    <tr><td id="target">The Target Element for the Ajax Submit</td></tr>
</table>

<br/><br/>
<br/><br/>






<!-- DEMO 2 -->

<script type="text/javascript" >
    function validateForm(formObj){
        if(formObj.param1.value.length == 0){
            alert("Param1 must be more than 0 length");
            return false;
        }
        return true;
    }
</script>

<table class="tableBordered" width="300">
    <tr><td>Ajax Form Submit Example 2- JSP Ajax Tags, existing onsubmit function wrapped.</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>
        <ajax:form targetElement="target3">
            <form  action="ajaxFormReceiver.jsp" onsubmit="validateForm(this)">
            <input type="text"   name="param1" value=""/><br/>
            <input type="text"   name="param2" value="222"/><br/>
            <input name="submit1" type="submit" value="Submit1 - Button not submitted"/><br/>
            <ajax:submit>
                <input name="submit2" type="submit" value="Submit2 - Button Recognized"/>
            </ajax:submit><br/>
            <ajax:submit>
                <input name="submit3"   type="submit" value="Submit3 - Button Recongnized" />
            </ajax:submit><br/>
            </form>
        </ajax:form>
    </td></tr>

</table>

<br/><br/>
<table class="tableBordered" width="300">
    <tr><td id="target3">The Target Element for the Ajax Submit</td></tr>
</table>


<!-- DEMO 3 -->

<br/><br/>
<br/><br/>
<table class="tableBordered" width="300">
    <tr><td>Ajax Form Submit Example 3 - JavaScript Only!</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td><form action="ajaxFormReceiver.jsp" onsubmit="return com_jenkov_prizetags_ajaxSubmitForm(this, 'target2'); ">
        <input type="text"   name="param1" value="111"/><br/>
        <input type="text"   name="param2" value="222"/><br/>
        <input name="ajaxSubmit"   type="submit" value="Ajax Submit" onclick="com_jenkov_prizetags_ajaxButtonClicked(this)" /><br/>
    </form>

    </td></tr>

</table>

<br/><br/>
<table class="tableBordered" width="300">
    <tr><td id="target2">The Target Element for the Ajax Submit</td></tr>
</table>

<br/><br/>




<br/><br/>



</body>
</html>