Click to See Complete Forum and Search --> : import a vector from jsp into a javascript


digital_storm
10-19-2003, 05:06 AM
Hello!

Hello I'm a newbie of javascript and got three questions, nr 3 is my mainquestion:
1)
Where can I find an API for JS?

2)
When you declare a variable in JS don't you have to declare what kind of variable it is String, int etc. like in Java?

3)
I vant to import a vector ( "= elements") which have been initialized by a jsp-page. If i write;

var elements= <%start.getElements();%>

(start=my class which creates my vector element, getElements returns a Vector)

I get a "syntax error"

What should I do?

Thanks for helping me!

gil davis
10-19-2003, 08:51 AM
Originally posted by digital_storm
1) Where can I find an API for JS?Whose JS do you want?

Netscape - http://devedge.netscape.com/central/javascript/
Micro$oft - http://msdn.microsoft.com/library/en-us/script56/html/js56jsoriJScript.asp
2) When you declare a variable in JS don't you have to declare what kind of variable it is String, int etc. like in Java?[You don't necessarily have to declare any variables in JS. Sometimes it is helpful to use the "new" operator to create an object.
3) I vant to import a vector ( "= elements") which have been initialized by a jsp-page. If i write;

var elements= <%start.getElements();%>

(start=my class which creates my vector element, getElements returns a Vector)

I get a "syntax error"Try
var elements= <% Response.Write(start.getElements();)%>It might give you the right data.

pelegk1
10-19-2003, 09:00 AM
first can u guve an example of how your vector looks like?
and second do like this :
var elements= "<% out.println(start.getElements());%>";

Khalid Ali
10-19-2003, 11:03 AM
First of just a point,
I dont think there is any method in vector class called
getElements();
Vector class has method
elements()
which will return a enumeration,now
I don't think you can return an obect to a javascript variable,the most you can do is use
String.valueOf(vector.get(index))
get a single string vlaue and assign it to JS variable.