Autor Zpráva
Max-el
Profil *
Dobrý večer, mám tento kód v XML:

<script type="text/javascript">

for (var i = 0; i < document.hilite_form.elements.length; i++)
if (document.hilite_form.elements[i].type == 'checkbox'){
document.hilite_form.elements[i].checked = true;
}
</script>


problém mám se znamínkem "je menší" < nevíte co upravit, abyb byl kód funkční? když použiju &lt; tak to také nepomůže.
Bubák
Profil
http://atd.havrlant.net/jak-na-dokonale-xhtml
Max-el
Profil *
Dík, ty <![CDATA[ mi vůbec nenapadly
Chamurappi
Profil
Reaguji na Max-ela:
Nepomůže-li změna menšítka na &lt;, tak nepomůže ani CDATA sekce. <![CDATA[<]]> a &lt; je vždy totéž.
Max-el
Profil *
Jo, to sem zpozoroval, že ten script stejnak nefunguje =(
A co tedy s tím? Víte někdo?
Timy
Profil
Max-el
element <script> v obecném XML nic neznamená... Zkus to takhle:

<script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">
Max-el
Profil *
to nevim jestli něco znamená, nebo neznamená, každopádně tam mám ještě jiné
<script type="text/javascript">
a ty fungují normálně. To Tvoje řešení taky nefunguje.
Max-el
Profil *
nemám třeba chybu někde tady?

<?xml version="1.0" encoding="UTF-8"?>

<!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="en" xml:lang="en">
Timy
Profil
Max-el
a napadlo tě taky, že můžeš mít špatně ten JS? Bez celého kódu asi nikdo neporadí.
Max-el
Profil *
to sem asi zapoměl napsat, všechno to funguje bez problémů, pokud je to HTML, když je to ale XML už to neběží
Dero
Profil
Max-el: Jistěže ne, v XHTML posílaném jako XML kolekce elements ve výchozím stavu neexistuje a objekt hilite_form pravděpodobně také ne.

Co tak zkusit tohle:

<script type="text/javascript">

elements = document.getElementById("hilite_form").getElementsByTagName("input");
for (var i = 0; i < elements.length; i++)
if (document.hilite_form.elements[i].type == 'checkbox'){
elements[i].checked = true;
}
</script>



Lepší by bylo vyhnout se i volání getElementById a nahradit deklaraci elements například takto:

elements = document.getElementsByTagName("form")[0].getElementsByTagName("input");
Max-el
Profil *
Timy: Bez celého kódu asi nikdo neporadí.
tady jsou ty soubory:
http://mapa.stod.info/index.html
http://mapa.stod.info/index.xml

jde mi o to, že se v tý SVG mapě u XML nevypínají jednotlivý vrstvy

2 Dero jsem lama, takže mi to moc nepomohlo. To co tam teď používám, sem našel jako hotové řešení na http://www.carto.net/ , akorát sem si to přizpůsobil.
Dero
Profil
Max-el: V XML to nemůže fungovat. Jak píšu, musíš k jednotlivým prvkům přistupovat DOM metodami. Počkej, přepíšu Ti ten XML dokument.
Dero
Profil
Max-el:

Funkční XML konstrukt:


<?xml version="1.0" encoding="UTF-8"?>
<!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="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Mapa Stoda</title>

<style type="text/css">

body {
margin: 0;
padding: 0;
line-height: 1.5em;
}
b {
font-size: 110%;
}
em {
color: red;
}
#topsection {
background: #EAEAEA;
height: 50px;
/*Height of top section*/
}
#topsection h1 {
margin: 0;
padding-top: 15px;
}
#contentwrapper {
float: left;
width: 100%;
}
#contentcolumn {
margin-right: 200px;
/*Set right margin to RightColumnWidth*/
}
#rightcolumn {
float: left;
height: 700px;
width: 200px;
/*Width of right column in pixels*/
margin-left: -200px;
/*Set left margin to -(RightColumnWidth) */
background: #FDE95E;
}
#footer {
clear: left;
width: 100%;
background: black;
color: #FFF;
text-align: center;
padding: 4px 0;
}
#footer a {
color: #FFFF80;
}
.innertube {
margin: 10px;
/*Margins for inner DIV inside each column (to provide padding)*/
margin-top: 0;
}
</style>

<script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
function layer(checkbox, element_name){
//get a reference to the svg document and then to a group with the given id
var svgobj = document.getElementsByTagName('embed')[0].getSVGDocument().getElementB yId(element_name);
if (!checkbox.checked){
// Hide layer.
svgobj.setAttributeNS(null,'visibility','hidden');
} else {
// Show layer.
svgobj.setAttributeNS(null,'visibility','visible');
}
}



var content=new Array()
//change the array below to the text associated with your links Expand or contract the array, depending on how many links you have
content[0]='<strong>Menus and navigation systems</strong><br/>Informace o sportovních zařízeních'
content[1]='<strong>Menus and navigation systems</strong><br/>Informace o parcích a relax. částech města'
content[2]=''
content[3]='<strong>Menus and navigation systems</strong><br/>Informace o institucích'
content[4]='<strong>Menus and navigation systems</strong><br/>Informace o vodě - společnosti, mik-radbuza'
content[5]=''

function changetext(whichcontent){

if (document.all||document.getElementById){
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions
cross_el.innerHTML='<font face="Verdana">'+whichcontent+'</font>'
}
else if (document.layers){
document.d1.document.d2.document.write('<font face="Verdana">'+whichcontent+'</font>')
document.d1.document.d2.document.close()
}

}

window.onload=regenerate2

]]></script>

</head>
<body>
<div id="maincontainer">
<div id="topsection"><div class="innertube"><h1>HLAVIČKA</h1></div></div>
<div id="contentwrapper">
<div id="contentcolumn">
<div class="innertube">
<object>
<embed width="100%" height="730" src="stod.svg" name="printable_map" type="image/svg+xml"/>
</object>
</div>
</div>
</div>

<div id="rightcolumn">
<div class="innertube">
<h2>Jednotlivé vrstvy</h2>
<form name="hilite_form" action="">
<ul><li onMouseover="changetext(content[0])"><input type="checkbox" value="" onclick="layer(this,'sport')"/>Sport</li>
<li onMouseover="changetext(content[1])"><input type="checkbox" value="" onclick="layer(this,'zelen');layer(this,'zelen_v_asfaltu')"/>Zeleň</li >
<li onMouseover="changetext(content[2])"><input type="checkbox" value="" onclick="layer(this,'domy')"/>Domy</li>
<li onMouseover="changetext(content[3])"><input type="checkbox" value="" onclick="layer(this,'instituce')"/>Instituce</li>
<li onMouseover="changetext(content[4])"><input type="checkbox" value="" onclick="layer(this,'voda')"/>Voda</li>
<li onMouseover="changetext(content[5])"><input type="checkbox" value="" onclick="layer(this,'vedlejsi_silnice')"/>Vedlejší silnice</li>
<li onMouseover="changetext(content[6])"><input type="checkbox" value="" onclick="layer(this,'zeleznice')"/>Železnice</li>

<li onMouseover="changetext(content[7])"><input type="checkbox" value="" onclick="layer(this,'hlavni_silnice')"/>Hlavní silnice</li>
<li onMouseover="changetext(content[8])"><input type="checkbox" value="" onclick="layer(this,'parkoviste')"/>Parkoviště</li>
<li onMouseover="changetext(content[9])"><input type="checkbox" value="" onclick="layer(this,'texty')"/>Texty</li>
<li onMouseover="changetext(content[10])"><input type="checkbox" value="" onclick="layer(this,'info')"/>Popisky</li>
<li onMouseover="changetext(content[11])"><input type="checkbox" value="" onclick="layer(this,'legenda')"/>Legenda</li>
</ul>
<script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
// Make sure all checkboxes are checked whenever the page is reloaded in the browser.
var hform = document.getElementsByTagName("form")[0];
var elements = hform.getElementsByTagName("input");

for (var i = 0; i < elements.length; i++)
if (elements[i].getAttribute('type') == 'checkbox'){
elements[i].setAttribute('checked', true);
}
]]></script>
</form>
<h2>Další info</h2>
<a href="stod.svg" target="_self">Maximalizovat mapu</a>

<layer id="d2" width="200" height="200">
<ilayer id="d1" width="200" height="200" visibility="hide">
<div id="descriptions" align="left">

</div>
</ilayer>
</layer>
</div>
</div>
</div>
</body>
</html>
Max-el
Profil *
teď sice vidím zaškrtnuté checkboxy, ale mapa na ně stejnak nereaguje
Dero
Profil
Max-el: Odzkoušeno na Firefoxu 2.0, funguje. Který prohlížeč zlobí?
Max-el
Profil *
=) Firefox 2.0 a nebo jsem tupej
Dero
Profil
http://83.240.10.78/Testcase/mapa/index.xml

Tady je moje testovací verze.
Toto téma je uzamčeno. Odpověď nelze zaslat.

0