User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 403,401 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,644 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1314 | Replies: 1
Reply
Join Date: Jun 2006
Posts: 60
Reputation: dev.cplusplus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
dev.cplusplus's Avatar
dev.cplusplus dev.cplusplus is offline Offline
Junior Poster in Training

Help Run Script Dinamically

  #1  
Feb 10th, 2008
Hi to all, I was wandering if I can do the following thing:
I need a page that I can input a piece of script:
e.g.
<script>
function Test(mystring)
{
if (mystring !="")
alert("OK");
else
alert("NotOK");
}
</script>

And click a button and run the script in the page.
The Script can be anything.

I found a way to insert a script in my page like
//mydiv is the place were I want to inser the page
var ni = document.getElementById('myDiv');
//create script object
var element = document.createElement('script');
//set attribute src with the script I insert
element.setAttribute("src",strScript);
ni.appendChild(element);

The problem is that the above piece code insert the script in the page, but doesn't run it.
I can see that the script was added, but nothing happens
Help, Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Location: georgia
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Run Script Dinamically

  #2  
Feb 11th, 2008
<input type="button" onclick="javascript: Test(mystring)" name="clickMe" value="Update Now!" />
toast
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:50 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC