Friday, December 25, 2009

Wart Removal Walk In Clinic Toronto

second example of jquery with jsp


the following example using jsp with jdbc, style sheet, it's going
text capture, save and rescue, to show in sequence after
down

insert.jsp


\u0026lt; % @ page contentType = "text / html"%>

\u0026lt;% @ page pageEncoding = "UTF-8"%>

\u0026lt;% @ page language = "java" import = "java.sql .* "errorPage =" "%> \u0026lt;script type="text/javascript" src="js/jquery-1.3.1.js">



\u0026lt;/ script>

\u0026lt;link rel="stylesheet" href="code.css" type="text/css" media="all" />

<script type="text/javascript" >

$(function() {

$(".update_button").click(function() {

var boxval = $("#content").val();

var dataString = 'content='+ boxval;

if(boxval=='')
{
alert("introduzca texto");

}else

{
$.ajax({

type: "POST",
url: "demo.jsp",
data: dataString,
cache: false,
success: function(html){

$("ol#update").prepend(html);
$("ol#update li:first").slideDown("slow");
$("#content").value('');
$("#content").focus(); $("#flash").hide();
}
});

} return false;
});
});

</script>
<div>
<form method="post" name="form" action="">
<h3>ingrese Comuna</h3>
<textarea cols="30" rows="2" name="content" id="content" maxlength="145" >
</textarea><br />
<input type="submit" value="Ingresar" name="submit" class="update_button"/>
</form>
</div>
<div id="flash"></div>
<ol id="update" class="timeline">
</ol>

demo.jsp


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*" errorPage="" %>
<%

String content = request.getParameter ("content");

try {Class.forName ("org.postgresql.Driver");
Connection con =

DriverManager.getConnection ("jdbc: postgresql: / / localhost / example "," postgres "," 1234 ");
Statement st = con.createStatement ();
int i = st.executeUpdate
(" insert into communes (name) values \u200b\u200b('"+ content +"')"); ResultSet rs =

st.executeQuery
("select * from order by name desc commune");

if (rs.next ()) {

while (rs.next ()) {

String msg = rs . getString ("name");
%>
\u0026lt;li> \u0026lt;div>

\u0026lt;span> \u0026lt;% = msg%> \u0026lt;/ span>
\u0026lt;/ div>
\u0026lt;/ li>
\u0026lt;%

}}

else {out.println ("error");}}

catch (Exception e) {

Exception ex = e;
out.println ("Error connecting to postgres:" + ex);}

%>

data base is a simple table called commune
with a field called name and nothing else.

now create the style sheet in netbeans
we can create new web ,
cascading style sheet.


root {display: block;}


* {margin: 0; padding: 0;}
ol.timeline
{list-style: none; font-size: 0.8em;}


ol.timeline
li {display: none; position: relative;
padding: .7 em 0 .6 em 0;
border-bottom: 1px dashed # 000;
line-height: 0.8em;
background-color: # D3E7F5;
height:

ol.timeline 25px} li: first-child {
border-top: 1px dashed # 000;}


intersante found these examples very well and are self

filled with a text link with java
to enter more in detail we have this other link ,
also this example which is a dependent combo with jsp and ajax
and last link to get more link jQuery indetail



0 comments:

Post a Comment