auswahl1 is not defined

Sancheck

Legendäres Mitglied
Hallo,
ich hab hier einen dynamisch generierten HTML Code und ein eigenartiges Problem.

Wenn ich die Methode dourlchange() aufrufe, bekomme ich die Fehlermeldung "auswahl1 is not defined" in Firebug

auswahl1 existiert aber,.....

CODE
<!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" >
<head><meta content="yes" name="apple-mobile-web-app-capable" /><meta content="index,follow" name="robots" /><meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" /><link href="pics/homescreen.gif" rel="apple-touch-icon" /><meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /><link href="css/style.css" rel="stylesheet" media="screen" type="text/css" /><link rel="stylesheet" href="css/queryLoader.css" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript' src='javascript/queryLoader.js'></script>

<script type='text/javascript' src='javascript/cookie.js'></script>


<script type='text/javascript' src='javascript/functions.js'></script>
<link href="pics/startup.png" rel="apple-touch-startup-image" /><title>
pharao mobile
</title>

<script type='text/javascript'>
$(document).ready(function(){
document.getElementById("topbar").style.display = "block";
document.getElementById("footer").style.display = "block";
document.getElementById("content").style.display = "block";
dokeepactive();
});
function dourlchange(){
$("#bild").attr("src",auswahl1.options[auswahl1.selectedIndex].value);

}
function dokeepactive(){

thr=window.setInterval("keepactive()", 10000);
}
function keepactive(){
$.ajax({
type: "GET",
async:true,
url: "../keepactive/"+"?time=_"+new Date().getTime(),
dataType: "html",
success: function(xml) {

}});
}
function home()
{

document.getElementById('content').style.display = 'none';
setTimeout("self.location.href='index4.aspx?time="+new Date().getTime()+"'",0);
}

</script>

</head>
<body>
<form name="form1" method="post" action="video.aspx?time=3" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJOTQwNzQxNTc5D2QWAgIDD2QWAgIBDxBkDxYCZgIBFgIQBQhLYW1lcmEgMQU8aHR0cDovL3d3dy5waGFyYW8ubW9iaTo5Mi9tanBnL3ZpZGVvLm1qcGc/cmVzb2x1dGlvbj0zMjB4MjQwZxAFCEthbWVyYSAyBTxodHRwOi8vd3d3LnBoYXJhby5tb2JpOjkzL21qcGcvdmlkZW8ubWpwZz9yZXNvbHV0aW9uPTMyMHgyNDBnZGRkcS5qQ1EMwBhgvk3ywz+QF6NAjvY=" />
</div>

<div>

<div id="topbar"style="display:none">

<div id="leftbutton">
<a href="index4.aspx">Home</a></div>
<div id="title">
Video</div>
</div>

<div id="content"style="display:none">
<ul class="pageitem"><br><li class="bigfield">
<select name="auswahl1" id="auswahl1">
<option value="http://www.test.de/mjpg/video.mjpg?resolution=320x240">Kamera 1</option>
<option value="http://www.test.de:93/mjpg/video.mjpg?resolution=320x240">Kamera 2</option>
</select></li>
<li class="bigfield"><input name="Senden" onclick="dourlchange();" type="button" value="Waehlen" /></li>
</ul>

<img id="bild" src="p1.jpg"></img>

</div>
<div id="footer" style="display:none">

</div>

<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKo86+wAgKbnsHOBfuXUgTaSQrWsRThBT0D24bxrQ4R" />
</div></form>
</body>
</html>

 
Versuchs mal mit:
CODE
function dourlchange(){
var auswahl1 = $("select[id='auswahl1'] option:selected").val();
$("#bild").attr("src", auswahl1);
}

 
auswahl1 ist - so verwendet - eine Variable ohne Wert. Daß es zufälligerweise ein Element mit derselben ID gibt, sieht JavaScript nicht.


CODE var auswahl1 = document.getElementById('auswahl1');


sollte das Problem beseitigen.
 
Zurück
Oben