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 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    nother noob problem

    They work when all in one page, but not when I try to make a JS file. Here's my html:

    <html>
    <head><title>combobox</title>
    <script language="javascript" src="combobox.js" type="text/javascript"></script>
    </head>
    <body>
    <script language="javascript">window.onload=drawCombobox;
    </script>
    </body>
    </html>

    here's the JS file:
    function drawCombobox(){
    document.write("<table border=1 cellpadding=3 cellspacing=0 bordercolor=#000000

    onClick='showhide(1);event.cancelBubble=1'><tr><td><span

    style='cursor:hand'><b>Name</b></span></td></tr></table>")
    document.write("<div id='innermenu'

    style='position:relative;left:0;top:0;width:240px;height:100px;border:1px solid

    black;background-color:white;overflow-y:scroll;visibility:hidden'>")
    function addLink(linkname,url){
    document.write("<a href='"+url+"'>"+linkname+"</a><br>")
    }
    function showhide(state){
    var cacheobj=document.getElementById("innermenu").style
    if (state==0)
    cacheobj.visibility="hidden"
    else
    cacheobj.visibility=cacheobj.visibility=="hidden"?"visible":"hidden"
    }
    addLink("Any site name","http://www.anysite.com")
    addLink("Any site name","http://www.anysite.com")
    document.onclick=function(){showhide(0)}
    document.write("</div>")
    }


    please help, 2 days trying to solve.
    thx,
    Jennifer

  • #2
    New Coder
    Join Date
    Nov 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your

    function drawCombobox(){

    have several line breaks:
    Code:
    function drawCombobox(){document.write("<table border=1 cellpadding=3 cellspacing=0  bordercolor=#000000 here 
    onClick='showhide(1);event.cancelBubble=1'><tr><td><span  here 
    style='cursor:hand'><b>Name</b></span></td></tr></table>")
    document.write("<div id='innermenu'  here 
    style='position:relative;left:0;top:0;width:240px;  here 
    height:100px;border:1px solid  here 
    black;background-color:white;overflow-y:scroll;visibility:hidden'>")
    which shouldn't be there.
    Try again after removing them.

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi, those line breaks are just from posting the questions here, and aren't in the original JS file.
    ~jenn


  •  

    Posting Permissions

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