Explorer liest .value nicht aus Formular
Patric
- javascript
0 Hans0 Patric
0 Der Martin
Hallo.
Ich hab ein Javascript-Movie-Tool gebastelt (bzw. modifiziert). Dies funktioniert unter Mozilla/Firefox und Opera auch in soweit, wie ich es erwarte (es sind noch ein paar Bugs zu entfernen).
Unter dem IE allerdings geschieht gar nichts, da das einlesen der Formulardaten wie Startzeit und Laufzeit etc. nicht funktioniert.
Gebe ich zum Beispiel den Wert document.form.startyear.value aus, zeigt mir der Internet Explorer nichts an.
Kann mir jemand sagen, was in dem Skript falsch läuft?
Vielen Dank für eure Hilfe,
Patric.
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="White">
<CENTER>
<TABLE BORDER="10" CELLPADDING="8">
<TR>
<TD align="center">
<img src = "http://www.xxxx.de/speicher/20060711/WC_20060711_1000.jpg" NAME=animation width="320" height="240" onError="this.src='tempgif.gif'">
</TR>
</TABLE>
<P>
<FORM NAME="form">
<INPUT TYPE=button VALUE="Faster" onClick="delay/=inc; show_delay();">
<INPUT TYPE=button VALUE="Slower" onClick="delay*=inc; show_delay();">
<INPUT TYPE=button VALUE="Step" onClick="step();">
<INPUT TYPE=button NAME="direction" VALUE="Reverse" onClick="reverse();">
<INPUT TYPE=button VALUE="Swing_Mode" onClick="swing_mode();">
<br>
Starttime(yyyy,mm,dd,hh,mm):
<select name="startyear">
<option selected>2006
</select>
<select name="startmonth">
<option selected>07
</select>
<select name="startday">
<option selected> 10
</select>
<select name="starthour">
<option selected> 10
<option> 11
</select>
<select name="startmin">
<option selected>00
<option> 30
</select>
<br>
Runtime:
<select name="runtime">
<option selected> 04
</select>
<select name="timeunit">
<option> min
<option selected> hour
<option> day
</select>
<br>
Show each
<select name="framestep">
<option>01
<option selected> 05
</select>
th frame.
<br>
<INPUT TYPE=button VALUE="Start/Stop" onClick="startstop();">
<INPUT TYPE=button VALUE="Reload" onClick="reload();">
<BR>
Info: <INPUT TYPE=text VALUE="" NAME="frame" SIZE=30>
</FORM>
</CENTER>
</BODY>
</HTML>
<SCRIPT type="text/javascript">
var imax = 10, inc = 1.50, delay = 250;
var max_frames=600;
var num_loaded_images = 0;
var frame=-1;
var timeout_id=null;
var dir=1, playing=0;
var run = 0;
var bname = "Reverse";
var swingon = 0;
var images;
//function to start and stop the movie
function startstop()
{
if(timeout_id == null) animate();
else stop_play();
}
//function to reload all form entries
//core of the script
function reload()
{
var n_frames=1;
var sframestep=document.form.framestep.value;
framestep=parseInt(sframestep);
switch (document.form.timeunit.value)
{
case "min":
n_frames=1;
break;
case "hour":
n_frames=60;
break;
case "day":
n_frames=1480;
break;
}
all_frames=Math.round(document.form.runtime.value*n_frames/document.form.framestep.value);
document.form.frame.value = "Number of Frames:"+ all_frames;
if (all_frames > max_frames)
{
document.form.frame.value = "too many frames:"+ all_frames;
stop_play();
}
imax=all_frames;
delete images;
images = new Array(imax);
for (var i = 0; i < imax; i++)
{
images[i]= new Image();
images[i].onload=count_images;
images[i].src= "tempgif.gif";
}
//Get time variables
var syear=document.form.startyear.value;
var smonth=document.form.startmonth.value;
var sday=document.form.startday.value;
var shour=document.form.starthour.value;
var smin=document.form.startmin.value;
year=parseInt(syear);
month=parseInt(smonth);
day=parseInt(sday);
hour=parseInt(shour);
min=parseInt(smin);
//actual loading is done here
for (var i = 0 ; i < imax; i++)
{
//Where to take the images from
address="http://www.xxxxx.de/speicher/";
//Add leading zero if time variables are <10
if (min<10) {smin=''+0+min;}
else {smin=min+'';}
if (hour<10) {shour=''+0+hour;}
else {shour=hour+'';}
if (day<10) {sday=''+0+day;}
else {sday=day+'';}
if (month<10) {smonth=''+0+month;}
else {smonth=month+'';}
//Create image-link array
images[i].src=address+syear+smonth+sday+"/WC_"+syear+smonth+sday+"_"+shour+smin+".jpg";
//What to do when hour/day/month changes
min=min+framestep;
if(min>59)
{
min=0;
hour++;
}
if(hour>22)
{
hour=4;
day++;
}
if(day>30)
{
day=1;
month++;
}
if(month>12)
{
month=1;
year++;
}
}
}
// function to count images as they are loaded into cache
function count_images()
{
if (++num_loaded_images == imax){}
// animate();
else {
document.animation.src=images[num_loaded_images-1].src;
//document.form.frame.value="Loading "+num_loaded_images+" of "+imax;
}
}
reload();
// function to start movie
function start_play() {
if (playing == 0) {
if (timeout_id == null && num_loaded_images==imax) animate();
}
}
// function to stop movie
function stop_play() {
if (timeout_id) clearTimeout(timeout_id);
timeout_id=null;
playing = 0;
}
// function to control swing mode
function swing_mode() {
if (swingon) swingon=0; else swingon=1;
}
// function to do the animation when all images are loaded
function animate()
{
var j;
frame=(frame+dir+imax)%imax;
j=frame+1;
//images[frame].onError = tempgif(frame);
document.animation.src=images[frame].src;
document.form.frame.value="Displaying "+j+" of "+imax;
if (swingon && (j == imax || frame == 0)) reverse();
timeout_id=setTimeout("animate()",delay);
playing=1;
}
// function to control stepping thru each frame
function step()
{
var j;
if (timeout_id) clearTimeout(timeout_id); timeout_id=null;
frame=(frame+dir+imax)%imax;
j=frame+1;
document.animation.src=images[frame].src;
document.form.frame.value="Displaying "+j+" of "+imax;
playing=0;
}
// function to control direction of animation
function reverse()
{
dir=-dir;
if (dir > 0) document.form.direction.value="Reverse"; bname="Reverse";
if (dir < 0) document.form.direction.value="Forward"; bname="Forward";
}
</SCRIPT>
Hi !
<select name="startyear">
<option selected>2006
</select>
Also, ich hätte das bei IE 6.0 so geschrieben:
<select name="startyear">
<option value="2006">2006</option>
</select>
Und so darauf zugegriffen:
document.form.startyear.options[document.form.startyear.selectedIndex].value;
Gruß
Hans
Hi !
Hallo Hans!
<select name="startyear">
<option selected>2006
</select>Also, ich hätte das bei IE 6.0 so geschrieben:
Hmm, mal schaun....
<select name="startyear">
<option value="2006">2006</option>
</select>Und so darauf zugegriffen:
document.form.startyear.options[document.form.startyear.selectedIndex].value;
Ich habs so gemacht und es funktioniert nun bestens. Vielen Dank für deine Hilfe!!!
Gruß
Hans
Viele Grüße,
Patric.
Hi,
Gebe ich zum Beispiel den Wert document.form.startyear.value aus, zeigt mir der Internet Explorer nichts an.
das ist korrekt. Das Element mit dem Namen startyear ist in deinem Code-Beispiel ein <select>, und diese Elemente haben kein value. Stattdessen haben sie ein selectedIndex, mit dem man auf die options-Collection zugreifen kann. Die einzelnen option-Elemente haben ihrerseits auch wieder ein value.
Dass der Firefox auch dem <select> ein value andichtet, ist ein pures freundliches Entgegenkommen, aber dazu ist er nicht verpflichtet.
So long,
Martin