I think your solution will be to include multiple script tags with all of the required js files included, then you can use whichever one you need.
Main Topics
Browse All TopicsHi
How can i change the value of 'src' on drop down select event using javascript...
the src tag is here :
<script type="text/javascript" src="/shared/data/top3/Tor
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If the script runs in response to a user action, for example clicking a button or link, you could write the script to the page as an asp:literal control (http://www.w3schools.com/
<asp:Literal ID="Literal1" runat="server" Text="<script type='text/javascript' src='/shared/data/top3/Tor
if the script needs to run on page load, you will need to use ClientScript.RegisterStart
Technically, you can reset the src property of a script element, although I'm not so sure that it always works (meaning that it actually triggers the load of the new src URL). E.g., you can give your script element an ID, like:
<script id="myScript" type="text/javascript" src="/shared/data/top3/Tor
and then access it and change its src property just like you would for an image.
var scriptElem = document.getElementById("m
scriptElem.src = 'someOther.js';
However, again, while you can do this, when I've tinkered with it, it hasn't always resulted in the new JS actually loading and being usable by the page.
Another option might be to place a block element, like a div, whose innards you can rewrite, like:
<div id="scriptPanel"></div>
and
var divElem = document.getElementById('s
divElem.innerHTML = '<script type="text/javascript" src="someOther.js"></scrip
I don't think I've actually tested that one much in terms of being able to reference functions defined in the someOther.js, but I have seen document.write statements in a JS file loaded this way work just fine (in fact a lot of Web advertising services deliver their ads in a manner similar to this).
Hope some of that helps...
thats the prob. i even cant see what is the error ...but anyways i can give u the code and im sure that u can figure it out whats the error and how to fix it ..
<%@ Page language="VB" Inherits="SOV.CommonTempla
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html
<html>
<head>
<asp:Literal id="metaTitle" Visible="False" Text="Gateway Cities" runat="server"/>
<meta name="description" content="">
<meta name="keywords" content="">
<asp:PlaceHolder id="metaData" runat="server"/>
<link href="/includes/vas.css" rel="stylesheet" type="text/css">
<script type="text/JavaScript">
<!--
var scriptElem = document.getElementById("m
scriptElem.src = '/shared/data/top3/Quebec.
var city='toronto_ON';
var scrollerheight="210px";
// -->
</script>
</head>
<body>
<asp:PlaceHolder id="pageHeader" runat="server" />
<div id="content">
<script id="myScript" type="text/javascript" src="/shared/data/top3/Tor
<form name="city_selector" method="post" action="#">
</form>
</div>
<asp:PlaceHolder id="pageFooter" runat="server" />
</body>
</html>
and below is the code behined:
Imports Microsoft.VisualBasic
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace SOV
Public Class Homepage
Inherits SOV.CommonTemplate
Private Sub Page_Load
End Sub
End Class
End Namespace
thanks for your great help
Since this is an aspx page, use asp.net to do what it does well, rather than trying to fake it with javascript.
replace this part
<script id="myScript" type="text/javascript" src="/shared/data/top3/Tor
with
<asp:Literal ID="Literal1" runat="server" Text="<script type='text/javascript' src='/shared/data/top3/Tor
Add
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem>Toronto</asp
<asp:ListItem>Ontario</asp
</asp:DropDownList>
for the dropdownlist event handler put this code
Protected Sub DropDownList1_SelectedInde
Select Case DropDownList1.SelectedItem
Case "Toronto"
Literal1.Text = "<script type='text/javascript' src='/shared/data/top3/Tor
Case "Ontario"
Literal1.Text = "<script type='text/javascript' src='/shared/data/top3/Ont
End Select
End Sub
first, install ajax on the web server:
http://ajax.asp.net/
then on the page, right after the form tag add
<asp:ScriptManager ID="ScriptManager1" runat="server" />
Then wrap this around the DDL and literal
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
Ajax sounds complex at first, but once you get it installed, it is actually very simple
AJAX may very well get you want you're looking for, depending on what new script you're trying to load. The AJAX call goes back to the server, but it doesn't require the page itself to do so, so it's very similar to what you were experimenting with before. (OTOH, I'm always a little wary of the Golden Hammer syndrome, especially with ASP.NET...)
I'm a little perplexed by your code posting above (06.27.2007 at 05:56AM PDT).
1. You're missing a close-bracket with the line
<script id="myScript" type="text/javascript" src="/shared/data/top3/Tor
which should be
<script id="myScript" type="text/javascript" src="/shared/data/top3/Tor
2. Your JavaScript code above is running in-line and before the myScript element appears, which means that when the script runs, the element doesn't exist yet, so it won't find it. You could take the
<script type="text/JavaScript">
<!--
var scriptElem = document.getElementById("m
...
</script>
block and move it down below the myScript element, but... Done this way, you might as well forget the script and just put the new '/shared/data/top3/Quebec.
3. That's the method that I didn't really expect to work anyway, but... Did you try my other suggestion above at all?
This much all makes we want to ask: What exactly are you trying to accomplish here? What brought up the need to dynamically modify the <script> element's src attribute? ('Cause I don't see such a need in your code sample above.)
Business Accounts
Answer for Membership
by: jasonsbytesPosted on 2007-06-26 at 07:05:29ID: 19363754
I don't know that you can change the src of a script tag using javascript...