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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Modify a <script> tag content

    Hi I am a new user to JS, and I have a problem here:

    I have some JS code to work on a data set with file name "data.txt" in the header section of an HTML page.
    Code:
    <script type="text/javascript" src="data.txt"></script>
    What I am trying to do is to ask a user to input a different file name, then update the file name in the <script> tag, for example, to

    Code:
    <script type="text/javascript" src="new_data.txt"></script>
    But I don't know how to update the file name. Any help will be appreciated.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    627
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Try this: Once you have the UserInput:
    Code:
    Out='<script type="text/javascript" src="'+UserInput'+"></script>';
    document.write(Out);


  •  

    Posting Permissions

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