View Full Version : Modify a <script> tag content

07-09-2011, 06:05 PM
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.

<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

<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.

07-09-2011, 11:21 PM
Try this: Once you have the UserInput:

Out='<script type="text/javascript" src="'+UserInput'+"></script>';