Forum: Rails Spinoffs (closed, excessive spam) Formating Date Field

12e5af8b643a158e46f887337f289e35?d=identicon&s=25 raku (Guest)
on 2008-06-17 14:26
(Received via mailing list)
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?
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-18 15:36
(Received via mailing list)
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.
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-18 15:41
(Received via mailing list)
And why do you have <html><body> in your Ajax.jsp?  You just want to
output
a plain value.

-Fred

On Tue, Jun 17, 2008 at 7:25 AM, raku <rajkumarvutukuru@gmail.com>
wrote:

> {
> out.print(rs.getString(1));
> }
> }
>

--
Science answers questions; philosophy questions answers.
This topic is locked and can not be replied to.