PDA

View Full Version : نوشتن در div به وسیله انتخاب listbox



mohsen.dbnet
شنبه 22 مهر 1391, 08:23 صبح
با سلام خدمت اساتید محترم
مشکل این کد چیه
چرا وقتی یکی از فیلد های لیست باکس رو انتخاب می کنم داده مورد نظرم توی DIV_2 دوم نوشته نمی شه

کد:



<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function display_1(){
var x=document.getElementById('s1');
if(x.options[0].selected==true)
document.getElementById('left').innerHTML="آسمان آبی";
else
document.getElementById('left')innerHTML="زمین سرسبز";

}
</script>
</head>

<body>
<div style="
position:relative;
width:640px;
height:400px;
background-color:#9CF;
margin:0 auto;
top:200px;
">

<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<form name="form1" >
<div style="position:absolute;width:280px;height:150px;backgro und-color:#9C9;left:340px;top:10px;text-align:right;">
DIV_1
<select id="s1" name="s1" size="1" style="position:absolute;top:60px; right:90px;text-align:right;" dir="rtl" >
<option value="cho1" selected="selected" onchange="display_1();" >آسمان
<option value="cho2" onchange="display_1();">زمین
</select>
</div>
<!-- left -->
<div id="left" name="left" style="position:absolute;width:280px;height:150px;backgro und-color:#9C9;left:20px;top:10px; ">
DIV_2
</div>
</form>

</div>
</body>
</html>