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));
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> 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?
>
>
>
>
> >
>
--
Science answers questions; philosophy questions answers.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > 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)); > } > } >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I use this for all my date inputs: http://www.frequency-decoder.com/2006/10/02/unobtrusive-date-picker-widgit-update On Jun 17, 8:19 am, raku <rajkumarvutuk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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)); > > } > }--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---