我正在创建一个具有以下行为的脚本:
为实现这一点,我有一个div
,然后加载视频然后删除,然后显示并删除下一个元素。可以想象,每个元素都有一个数组要显示,数组由索引处理。
实际上,即使表单未被删除也重新加载页面也与提交操作无关,我已经改为按钮以避免它。加载下一个视频时会重新加载。任何帮助都会被认可
<!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=iso-8859-1" />
<title>Bacteriología</title>
</head>
<body>
<script src="jquery-3.1.1.min.js"></script>
<script>
var preguntas=["De que trata la Bacteriología Diagnóstica?",
"Cuales son las Bacterias Procariotas?",
"no se",
"pero no importa"];
var movies=["../Bacteriologia/BactDiagDia1Parte1v.mp4","../Bacteriologia/BactDiagDia1Parte1.mp4","../Bacteriologia/BactDiagDiagParte11a.mp4","../Bacteriologia/BactDiagD1Parte 1_2a.mp4","../Bacteriologia/BacteiagD1 Parte 1_3a.mp4"];
var indexm=0;
var amovie=[0,0,1,2];
var apreg=[0,0,0,1,1,1,2,2,2,3,3,3,3]; //opciones asociadas a preguntas
var opciones=["de la vida y del amor","de la ausencia y de ti","de bacterias, microbios, y protozaurios","uno","dos","tres","unopp","dospp","trespp",
"unop","dosp","tresp","cuatrop"]
var movieactual=0;
function botonValidation(){
alert("en BVal"+movieactual);
mform=document.getElementById('newForm');
mform.parentNode.removeChild(mform);
};
function displayQButton(){
var i, j;
$form = $("<form></form>");
$form.attr('id', 'newForm');
$form.appendTo('#miArea');
for (i=0;i<apreg.length;i++) {
if (apreg[i]==movieactual){
nombre="boxCount"+i;
$('#newForm').append(opciones[i]);
var radioBtn = $('<input type="checkbox" name=nombre />');;
radioBtn.appendTo('#newForm');
var newElem = document.createElement("BR");
$('#newForm').append(newElem);
}
}
$form.append('<button onclick="botonValidation()">Sendme please</button>');
event.stopEvent();
//endofdisplayQuestion
}
function deleteVideo(id) {
Video=document.getElementById(id);
Video.parentNode.removeChild(Video);
alert("Video");
}//end of deleteVideo()
function loadVideo(nombre,id) {
mypara=document.getElementById("miArea");
var videlem = document.createElement("video");
videlem.id=id;
videlem.width="640";
videlem.height="480";
videlem.controls="controls";
videlem.setAttribute("onended", "videoEnded()");
videlem.setAttribute ("autoplay","autoplay");
var sourceMP4 = document.createElement("source");
sourceMP4.type = "video/mp4";
sourceMP4.src = nombre;
videlem.appendChild(sourceMP4);
mypara.appendChild(videlem);
}
function videoEnded() {
deleteVideo("video");
movieactual=movieactual+1;
movie=movies[movieactual];
displayQButton();
alert(movieactual);
loadVideo(movie,"video");
}
$(document).ready(function(){
alert("Loading Page;"+movieactual);
if(typeof(Storage) !== "undefined") {
movie=movies[movieactual];
loadVideo(movie,"video");
} else { alert ("Por favor actualice su browser ");}
});
</script>
</head>
<body>
<div id="miArea">
<form></form></div>
</body>
</html>