SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member draig_hand's Avatar
    Join Date
    May 2009
    Location
    Glasgow
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing fname in <Script src="folder/fname.js">

    My requirements simply put are:

    In my HTML <body> I have a script which produces the value “y” - document.f.y.value=d1+''+d2; The ‘value’ is always a two digit number (d1+" "+d2)

    Also in the <body> I have - <script src="quizpm/66.js">

    I want to replace the file name (66) with the value of "y" i.e. (d1+" "+d2)

    Can anyone provide the code to accomplish this?
    Note that I have tried and failed to create an ID and use getElementByID.

    Thank you.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,604
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    See http://javascript.about.com/library/bladdjs.htm for how to add a script tag into a page using JavaScript.

    If you want the tag inserted at the end of the body instead of the head you just substitute the one word in the script.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member draig_hand's Avatar
    Join Date
    May 2009
    Location
    Glasgow
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I managed to do it


    <head>
    document.scripts('script1').src='quizpm/'+d1+''+d2+'.js'

    <script src="quizpm/66.js" id='script1'></script>
    </head>

    Thanks for your help.


Bookmarks

Posting Permissions

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