javascript in div

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boogyman
    New Member
    • Sep 2009
    • 2

    javascript in div

    I'm trying to get a simple simple simple function to execute inside a div tag and i can't get the div tag to do what it normally should do... i've searched the web for answers with no luck... here is the relevent code:
    Code:
    <style ...
    div.spec
    {
    	border: none;
    	position:absolute;
    	top: 300px;
    	left: 75px;
    	width:492px;
    	height:auto;
    	text-align: center;
    )
    </style>
    ....
    
    <script ...
    
    function showSpecial()
    {
    document.write("Today's Special is " + specials);
    }
    
    -->
    </script>
    ..........
    <body ...
    
    <div class="spec">
    <script type="text/javascript">
    <!--
    showSpecial();
    -->
    </script>
    </div>
    the div shows the text... but it doesn't go where it should go... it just hangs at the top of the page... my other code free divs work fine though

    please help
    Last edited by Dormilich; Sep 20 '09, 07:35 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    using document.write( ) is a very outdated way to add content. to give advice I’d like to know, what you want to do there, currently I see no reason to use Javascript at all.

    btw, you didn’t define what the variable special is.

    Comment

    • boogyman
      New Member
      • Sep 2009
      • 2

      #3
      you can see the full code at lildaddysdownto wn.com basically the script is to have the different specials show on different days........ specials is defined, i just didn't include the code above

      if u look at the site, you can see the text is showing up behind the logo, not where it should be

      EDIT: I found the problem and feel like an idiot i put a ) vs } by accident, but I'd still like to know some advice on a better way than using document.write( )

      Comment

      Working...