0

Clients.evalJavaScript don' t work with datebox

asked 2011-04-15 16:04:14 +0800

soumaya gravatar image soumaya
99 1

Hi,

I need to use Clients.evalJavaScript inside zscript.
The probleme is I can't work with date.

if I write String start="2011-04-15" i don't get the result

Clients.evalJavaScript("alert("+start+");

thanks for any help

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-04-15 16:32:21 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

Please post a simple self-contained example which shows the problem.

Cheers, Maik

link publish delete flag offensive edit

answered 2011-04-16 02:01:30 +0800

soumaya gravatar image soumaya
99 1

updated 2011-04-16 05:35:31 +0800

Ok, i would really appreciate your help.
Below is a piece of my code.I need to send the selected date and list to a javascript function.

<zk>
		<window id="win">

		<groupbox id="gb" >
			
			<hbox>
				Date:
				<datebox id="startDate" format="dd-MM-yyyy" />
				
			</hbox>
			
			<listbox id="list">
				<listhead sizable="true">
				   
					<listheader label="list" />
					
					
				</listhead>
			</listbox>
			
			<button id="bt" label="send" onClick="test()" />

			
		</groupbox>


<zscript deferrred="true">

import java.text.SimpleDateFormat;
import java.text.DateFormat;


	void test() {
	
		DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
		String datestart=dateFormat.format(startDate.getValue());
		String list=list.getSelectedItem().getLabel();
		
		Clients.evalJavaScript("testjsfunction("+datestart+")");
	 
		}
	}
</zscript>

//javascript function wich call a servlet
function testjsfunction(parameter){
					
					$.getJSON("servlettest?parameter="+parameter+"",{} ,function(data){
				........
}

link publish delete flag offensive edit

answered 2011-04-18 21:00:35 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

no test you case, but it looks like you have wrong js. you miss quotes

Clients.evalJavaScript("testjsfunction('"+datestart+"')");

testjsfunction(' " + datestart + " ') " (add more space to show you)

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-04-15 16:04:14 +0800

Seen: 597 times

Last updated: Apr 18 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More