Toon posts:

gebruik jsp variabelen in javascript

Pagina: 1
Acties:

Verwijderd

Topicstarter
ik heb de volgende code:

ArrayList subject = new ArrayList();
ArrayList amount = new ArrayList();

// hier wat code weg gelaten, is niet relevant.

while (SQLResult.next())
{
semesterId = SQLResult.getString("semesterid");
subjectCode = SQLResult.getString("fagkode");
amount_of_students = SQLResult.getString("amout_of_students_result");
subjectName = SQLResult.getString("navn");

out.println("<tr span class='text1'><td>"+ subjectName +"</td><td>" + subjectCode + "</td><td>" + amount_of_students
+ "</td></tr>");
subject.add(subjectName);
amount.add(amount_of_students);

}
%>
</table>

<%=subject%>
<br>
<%=amount%>

<SCRIPT LANGUAGE="JavaScript">
// Even though they are only 44 bytes, let's preload our images
imRed = new Image();
imYellow = new Image();
imRed.src = "red.gif";
imYellow.src = "yellow.gif";

strImage = ""; // used for alternating colors

strToWrite = ""; // We'll dynamically build a table to hold
// our chart, then write it to the screen when ready

// Store the student scores, and their names
arScores = new Array(90,100,78,86,52,99,99,100);
arStudents = new Array("Alan", "Bob", "Joe", "Mary", "Dunce", "Sally", "Allison", "Jacob");

// rest van de code ook weggelaten is ook niet relevant


Nu wil ik dat de array arScores gelijk is aan de ArrayList amount en de array arStudents gelijk is aan de ArrayList subject. Omdat het eerste jsp is en het tweede javascript heb ik geen flaauw idee hoe ik dit moet doen. Ik heb al een aantal dingen geprobeerd, maar tot nu toe geen succes.
Heeft iemand een suggestie??

Eelco

  • Tsjipmanz
  • Registratie: Oktober 2000
  • Laatst online: 13-05 14:52

Tsjipmanz

Der Rudi ist da

Google gaf al snel http://java.sun.com/javaone/javaone2001/pdfs/1212.pdf als resultaat bij zoeken op "passing jsp variables to javascript"

Heb t snel doorgekeken maar denk dat hier wel instaan wat je moet hebben (wel een acrobat-reader nodig)

There's no such thing as a mistake, just happy accidents - Bob Ross
Relaxte muziek: altijd okee!
- Soulseek rulez -


Verwijderd

Topicstarter
Bedankt werkt nu!!