www.webdeveloper.com
Results 1 to 4 of 4

Thread: .write javascript function

Hybrid View

  1. #1
    Join Date
    Sep 2013
    Posts
    12

    .write javascript function

    HTML:
    HTML Code:
    <script src="stock.js" type="text/javascript">document.write(quantity_in_stock_S);</script>
    Javascript (stock.js):
    Code:
    var quantity_in_stock_S = 10
    I am wanting the HTML to print out the number 10 but it doesn't seem to be working. Any ideas?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    stock.js

    Code:
    var quantity_in_stock_S = 10;
    document.write(quantity_in_stock_S);
    html
    Code:
    <script src="stock.js" type="text/javascript"></script>
    </head>
    <body>
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Mar 2011
    Posts
    61
    When the src attribute is present on a script tag, it ignores the code between the opening and closing tag.

  4. #4
    Join Date
    Jun 2008
    Posts
    106
    document.write isn't a JavaScript function. It's a DOM method.

    Anyways... what the other posters said is correct. Put all your code in that script.js file, or use a separate script tag.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles