Ciao Ragazzi,
sono nuovo del forum e di javascript, ho bisogno di legare questi due file in un unico affinchè ad ogni voce della seconda select corrispondano tot opzioni cheched.
posto di seguito il primo file:
"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<title>Select dinamiche - Esempio JavaScript scaricato da HTML.it</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="it" />
<meta name="Robots" content="All" />
<meta name="Owner" content="HTML.it srl" />
<meta name="Author" content="HTML.it srl" />
<meta name="Copyright" content="HTML.it srl" />
<script type="text/javascript">
var regiondb = new Object()
regiondb["africa"] = [{value:"102", text:"Cairo"},
{value:"88", text:"Lagos"},
{value:"80", text:"Nairobi"},
{value:"55", text:"Pretoria"}];
regiondb["asia"] = [{value:"30", text:"Ankara"},
{value:"21", text:"Bangkok"},
{value:"49", text:"Pechino"},
{value:"76", text:"New Delhi"},
{value:"14", text:"Tokyo"}];
regiondb["australia"] = [{value:"64", text:"Suva"},
{value:"12", text:"Sydney"}];
regiondb["europa"] = [{value:"11", text:"Atene"},
{value:"35", text:"Francoforte"},
{value:"3", text:"Londra"},
{value:"15", text:"Madrid"},
{value:"1", text:"Parigi"},
{value:"10", text:"Roma"},
{value:"6", text:"Stoccolma"},
{value:"97", text:"San Pietroburgo"}];
regiondb["noamer"] = [{value:"73", text:"Dallas"},
{value:"71", text:"Los Angeles"},
{value:"5", text:"New York"},
{value:"37", text:"Toronto"}];
regiondb["suamer"] = [{value:"65", text:"Buenos Aires"},
{value:"31", text:"Caracas"},
{value:"66", text:"Rio di Janeiro"}];
function setCities(chooser) {
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["città"];
while (cityChooser.options.length) {
cityChooser.remove(0);
}
var choice = chooser.options[chooser.selectedIndex].value;
var db = regiondb[choice];
newElem = document.createElement("option");
newElem.text = "Seleziona una città:";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "") {
for (var i = 0; i < db.length; i++) {
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
"
function option(mauro){
if (regiondb["africa"]!=""){
document.write
<form name=myform>
Opzione 1<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(0)">
Opzione 2<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(1)">
Opzione 3<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(2)">
Opzione 4<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(3)">
Opzione 5<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(4)">
Opzione 6<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(5)">
Opzione 7<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(6)">
Opzione 8<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(7)">
</form>
}
}
</script>
</head>
<body >
<div align="center">
<h1>Esempio - Select dinamiche</h1>
<hr>
<form name="form">
Invia la richiesta a:
<select name="continente" onchange="setCities(this)">
<option value="" selected="selected">Seleziona un continente:</option>
<option value="africa">Africa</option>
<option value="asia">Asia</option>
<option value="australia">Australia/Oceania</option>
<option value="europa">Europa</option>
<option value="noamer">Nord America</option>
<option value="suamer">Sud America</option>
</select>
<select name="città">
<option value="" selected="selected">Seleziona una città:</option>
</select>
</form>
</div>
<div align="center">
[img]logo_htmlit.gif[/img]
</div>
</body>
</html>
"
ora posto il secondo
"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<title>Solo un Check - Esempio JavaScript scaricato da HTML.it</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="it" />
<meta name="Robots" content="All" />
<meta name="Description" content="HTML.it - il sito italiano sul Web publishing" />
<meta name="Keywords" content="Ad ogni apertura di pagina questo script genera un differente colore di sfondo." />
<meta name="Owner" content="HTML.it srl" />
<meta name="Author" content="HTML.it srl" />
<meta name="Copyright" content="HTML.it srl" />
<script type="text/javascript">
<!-- Begin
function checkBoxValidate(cb) {
for (j = 0; j < 8; j++) {
if (eval("document.myform.ckbox[" + j + "].checked") == true) {
document.myform.ckbox[j].checked = false;
if (j == cb) {
document.myform.ckbox[j].checked = true;
}
}
}
}
// End -->
</script>
</head>
<body>
<h1>Solo un check</h1>
<form name=myform>
Opzione 1<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(0)">
Opzione 2<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(1)">
Opzione 3<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(2)">
Opzione 4<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(3)">
Opzione 5<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(4)">
Opzione 6<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(5)">
Opzione 7<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(6)">
Opzione 8<input type="checkbox" name="ckbox" onclick="javascript:checkBoxValidate(7)">
</form>
<div align="center">
[img]logo_htmlit.gif[/img]
<span style="font-size:80%; color:gray">sponsor</span>
<script language="javascript" type="text/javascript">
<!--
var browName = navigator.appName;
var SiteID = 1;
var ZoneID = 24;
var browDateTime = (new Date()).getTime();
if (browName=='Netscape')
{
document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://adserver.html.it/a.aspx?ZoneID=' + ZoneID + '&Task=Get&IFR=False&Browser=NETSCAPE4 &PageID=90264&SiteID=' + SiteID + '&Random=' + browDateTime + '">'); document.write('</'+'scr'+'ipt>');
}
if (browName!='Netscape')
{
document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://adserver.html.it/a.aspx?ZoneID=' + ZoneID + '&Task=Get&IFR=False&PageID=90264& SiteID=' + SiteID + '&Random=' + browDateTime + '">'); document.write('</'+'scr'+'ipt>');
}
// -->
</script>
<noscript>
<a href="http://adserver.html.it/a.aspx?ZoneID=24&Task=Click&Mode=HTML& SiteID=1&PageID=90264" target="_blank">
</a>
</noscript></div>
</body>
</html>posto di seguito il primo file: posto il primo file
"
Come li lego???
per favore aiutatemi altrimenti perdo il posto!!!!