
August 15th, 2001, 04:10 AM
|
|
Gödelian monster
|
|
Join Date: Jul 1999
Location: Central Florida, USA
|
|
Being a Java newbie, I can't give you a definitive on how to pass the array to a client-side applet, although it should be possible.
As for passing it to something server-side there are only a couple ways: in a GET request on the query string or in a POST. No matter what, you will have to flatten the array with some method or other, to convert it into a text string that can be parsed on the other end.
I personally favor using hidden form elements and posting the data, because otherwise you have to worry about urlencoding your query string. You could just use javascript itself to write a series of hidden text inputs and then submit the form, so all your form handler has to do is pick up the variables.
Let's say the array is named "myarray":
Code:
<script language="Javascript">
document.writeln("<form name=\"myform\" method=\"POST\" action=\"myserver/myhandler.jsp\">")
for(i = 0; i < myarray.length; i++){
document.writeln("<input type=\"hidden\" name=\"myarray[" + i + "]\" value=\"" + myarray[i] + "\">")
}
document.writeln("</form>")
document.myform.submit()
</script>
I know this is clunky and "low-tech" but it will work, and has the benefit of working for any server-side platform that can handle forms.
|