Click to See Complete Forum and Search --> : Javascript Onload
dlisa
04-08-2004, 07:46 AM
i am using struts
in my Action class i set a String in request (its a date as String)
and in the jsp page i need to get the String
and pass it to a javascript
so can i while loading a jsp page
take the object from request
i mean how can i pass the date to this
this is my jsp
<script language="JavaScript">
show_calendar("April 30, 2004");
</script>
so instead on "April 30, 2004" i want to pass a variable
which is taken from the request object
David Harrison
04-08-2004, 11:51 AM
Well I read through your post a couple of times and I still don't understand you.
Can you explain it a little clearer?
If this is more of a JSP quesion than a JavaScript question then can't help you, but if not then I'm your guy.
dlisa
04-08-2004, 12:01 PM
hey
thanks for replying
this is a javascript question
in my jsp page
in the first part i have these calendar functions
and below
i have
<script language="JavaScript">
show_calendar("April 30, 2004");
</script>
so when this jsp page loads
this method show_calendar is invoked
which is written above
and it paints a calendar for me allright
but the thing is i am getting a calendar for the month
of Arpril 2004
but as u see i am hard coding this value
so when this jsp page is loaded i
in my previous Aciton class thru which i am coming i will have set the Date as a srring in request
so instead of the hardcoded value
when the jsp page is loaded i want to pass this Sting (which is in the request) to the method show_calendar
i hope i made myself clear
thanks
David Harrison
04-08-2004, 12:09 PM
So you want to find the date in JavaScript?
<script type="text/javascript"><!--
var d=new Date();
var date=d.getDate();
var month=d.getMonth();
var year=d.getYear();
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var datestring=monthArray[month]+" "+date+", "+year;
show_calendar(datestring);
//--></script>
dlisa
04-08-2004, 12:13 PM
hi
i think i confused you
no what i want to do is
<%
String date = (String) request.getAttribute("date");
%>
<script language="JavaScript">
show_calendar(date);
</script>
but i cannot do this
can u help
neil9999
04-08-2004, 12:18 PM
If you posted a link to/the code for your page, this would probably make your query more understandable.
Neil
David Harrison
04-08-2004, 12:50 PM
So it's a JSP question after all. Well I'll have a go:
<%
String date = (String) request.getAttribute("date");
%>
<script type="text/javascript"><!--
<%
response.write "show_calendar("&date&");"
%>
//--></script>
That's how it would look in ASP, (except that I would use <%= rather than response.write).
dlisa
04-08-2004, 01:59 PM
thanks very much
i would like this to work tho' i can try this out only on saturday
ill write back if it does
thanks for the prompt replies to both you and Neil
dlisa
04-10-2004, 03:47 AM
thanks a lot everyone esp lavalamp
the following worked
<%
String date = (String) request.getAttribute("date");
}
%>
<script language="JavaScript">
show_calendar("<%=date%>");
</script>
thanks
David Harrison
04-10-2004, 04:08 AM
Happy to help. :)