Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.write without deleting the other stuff on the webpage

    <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????

  • #2
    Regular Coder COBOLdinosaur's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    411
    Thanks
    2
    Thanked 32 Times in 32 Posts
    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&
    100% standards compliant code is 100% correct 100% of the time.
    one of my toys from my repository and perhaps some help getting help

    Cd&

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks for the help

    thanks for the help but i have no clue what u are taling about
    thanks again i am sure it work
    good job
    I just dont know how to get it to work
    Last edited by JAVAEOC; 10-25-2003 at 08:52 PM.

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.........

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THANKS BOTH OF YOU

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •