...

View Full Version : document.write without deleting the other stuff on the webpage



JAVAEOC
10-25-2003, 02:51 PM
<HTML>
<HEAD>
<script>

var i=0;
var A=0

function MusicNum(){
if(document.Form1.box0.checked==true){i+=1;};
if(document.Form1.box1.checked==true){i+=1;};
if(document.Form1.box2.checked==true){i+=1;};
if(document.Form1.box3.checked==true){i+=1;};
if(document.Form1.box4.checked==true){i+=1;};
if(document.Form1.box5.checked==true){i+=1;};
};

function Music(){
if(i==1){
if(document.Form1.box0.checked==true){document.write("<EMBED SRC=A.wma hidden=true>")};
if(document.Form1.box1.checked==true){document.write("<EMBED SRC=A.wma hidden=true>")};
if(document.Form1.box2.checked==true){alert("You chose 3");};
if(document.Form1.box3.checked==true){alert("You chose 4");};
if(document.Form1.box4.checked==true){alert("You chose 5");};
if(document.Form1.box5.checked==true){alert("You chose 6");};
}
else{alert("Please check one box, one and only one!!!!!")};
};

function Reset(){
i=0;
};

function All(){
MusicNum();
Music();
Reset();
};
</script>
</HEAD>
<BODY>
<FORM NAME=Form1>
<INPUT TYPE=CHECKBOX NAME=box0>
<INPUT TYPE=CHECKBOX NAME=box1>
<INPUT TYPE=CHECKBOX NAME=box2>
<INPUT TYPE=CHECKBOX NAME=box3>
<INPUT TYPE=CHECKBOX NAME=box4>
<INPUT TYPE=CHECKBOX NAME=box5>
</FORM>
<INPUT TYPE="button" value="get music" onClick=All()>
</BODY>
</HTML>


Here in the function Music() when i tell it to dcument.write("<embed src=a.wma>") it works and it also embeds it but it deletes all the other contend why and how cna i fix this????

COBOLdinosaur
10-25-2003, 07:31 PM
Put and empty div on the page as a container for the embed like this:

<div id="thediv">&nbsp;</div>

The instead to document write, just modify the inner HTML:


obj=documentgetElementById('thediv');

if(document.Form1.box0.checked==true){obj.innerHTML+='<EMBED SRC=A.wma hidden=true>';}
if(document.Form1.box1.checked==true){obj.innerHTML+='<EMBED SRC=A.wma hidden=true>';}


Cd&

JAVAEOC
10-25-2003, 07:49 PM
thanks for the help but i have no clue what u are taling about:confused:
thanks again i am sure it work
good job :thumbsup:
I just dont know how to get it to work :(

Willy Duitt
10-25-2003, 10:23 PM
Change this:
if(document.Form1.box0.checked==true) {
document.write("<EMBED SRC=A.wma hidden=true>");
}

To this:
if(document.Form1.box0.checked==true) {
document.getElementByID[playThis].innerHTML.value='<EMBED SRC=A.wma hidden=true>';
}

And add this division to write to in your body:
<div name="playThis"></div>

.......Willy

BTW: Why did you start another thread under a different title
when it is the same question. If I would have known.........:mad:

JAVAEOC
10-26-2003, 01:55 AM
THANKS BOTH OF YOU

but how can i do the same thing wiht radio buttons cus it wont work. :confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum