Alert vraagje

Status
Niet open voor verdere reacties.

rudra

Nieuwe gebruiker
Lid geworden
22 jul 2008
Berichten
1
Goedeavond allemaal,

Ik heb een vraagje ik ben bezig met een opdracht, maar ik kom niet verder dan een bepaald punt.
In deze script moet ik de aangeklikte keuzes naar voren halen met een alert.
Alleen weet ik niet hoe ik deze keuzes naar voren breng.
Weet iemand wat ik hier fout doe of hoe ik dit moet uitvoeren?

Alvast bedankt.

<html>
<head>
<script language="JavaScript" type="text/JavaScript">
<script type="text/javascript" language="javascript">
<!--

var keuze1,keuze2,keuze3;


function info()
{
window.status =("Welkom op deze fantastische site");
}

function info2()
{
window.alert("U heeft gekozen voor: keuze1,keuze2,keuze3");
}

//-->

</script>

</head>

<body onLoad="info()">
<table width="100%" border="1">
<tr>
<th colspan="4"</th>
</tr>
<tr>
<td> Uw lievelings kleur is </td>
<td onclick="this.style.backgroundColor='#999999'">Blauw</td>
<td onclick="this.style.backgroundColor='#999999'">Groen</td>
<td onclick="this.style.backgroundColor='#999999'">Rood</td>
</tr>
<tr>
<td>Uw lievelings dier is</td>
<td onclick="this.style.backgroundColor='#999999'">Kat</td>
<td onclick="this.style.backgroundColor='#999999'">Hond</td>
<td onclick="this.style.backgroundColor='#999999'">Paard</td>
</tr>
<tr>
<td>Uw lievelings eten is</td>
<td onclick="this.style.backgroundColor='#999999'">Patat</td>
<td onclick="this.style.backgroundColor='#999999'">Thais</td>
<td onclick="this.style.backgroundColor='#999999'">Spaans</td>
</tr>
<tr>
<td>Klik</td>
<td onclick="info2()">Hier</td>
<td>&nbsp </td>
<td>&nbsp </td>
</tr>
</table>
</body>
</html>
 
Variabelen kan je concateneren (= aan elkaar plakken) met het + teken, hetzelfde als optellen. Dus:
[JS]var test = "iets";

alert("De variabele test bevat " + test + "!");[/JS]

Anyway, je kan zoiets aan je onclick toevoegen:
HTML:
<td onclick="this.style.backgroundColor='#999999'; vraag2 = 'hond';">Hond</td>
en dan uiteindelijk alle vraag* variabelen alerten.
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan