First.jsp
------------------
<jsp:usebean id="db" class="db.dbClass" scope=session/>
<html>
<body>
<form action="MyAction.jsp" method="post">
<% ResultSet rs=db.executeQuery("select no,name from mytable");
while(rs.next())
{%>
<input type=checkbox value=<%=rs.getString(1)%> onclick=callJs(<
%=rs.getString(1)%>) >
<%}
%>
<input type=text name=displaydatetxt id=displaydate/>
</form>
<script>
function callJs(arg1)
{
var url="Ajax.jsp";
new Ajax.Request(url, {asynchronous: true,method: "post",parameters:
"ajaxrefno=" +arg1,
onSuccess: function(request) {
$('displaydatetxt').value =request.responseText;
},
onFailure: function(request) {
$('displaydatetxt').value =request.responseText;}
});
}
</script>
</body>
</html>
********************************
Now the Ajax.jsp
<html>
<body><%
if(request.getParameter("ajaxrefno")!=null)
{
ResultSet rs=db.executeQuery("select mydate from display_table where
number='"+request.getParameter("ajaxrefno")+"' ");
if(rs.next)
{
out.print(rs.getString(1));
}
}
*******************************************
The above code works fine...but the column mydate returns date in
default oracle date format..and if i want to format that date ...to
dd/mm/yyyy, but if i change the query to
select to_char(mydate,'dd/mm/yyyy') ....then in the First.jsp the
value of the ....displaydatetxt shows as ..undefined .
Is there any way to format the date value and send it as response..?
Any Ideas?
on 2008-06-17 14:26
on 2008-06-18 15:36
If your date is formatted, then onclick=callJs(<%= ... %>) won't work.
You'll end up with: callJs(1/1/2008) which will do some form of division
that is likely to be not what you wanted. ;-)
Put quotes around the scriptlet: callJs('<%= ... %>').
-Fred
On Tue, Jun 17, 2008 at 7:25 AM, raku <rajkumarvutukuru@gmail.com>
wrote:
> <input type=checkbox value=<%=rs.getString(1)%> onclick=callJs(<
> "ajaxrefno=" +arg1,
> ********************************
> }
>
>
>
>
> >
>
--
Science answers questions; philosophy questions answers.