import - Apply javascript with the script tag -


i have page users can creates own script modify texts on server (don't worry access restricted few users). users have 3 fields can fill, 1 name of rule, expression replace , last 1 replace with:

<label id="name">name: </label> <input type="text" name="rulename" size="50" id="rulename"></input> </br> <label id="input">replace: </label> <input type="text" size="50" name="inputstep1" id="inputstep1"></input> </br> <label id="output">by:</label> <input type="text" size="50" id="outputstep1"></input></br> 

after rules stored in file on server via php post (i'll spare unecessary details of command...). , rules listed in form checkboxes, , want when checkboxes clicked rule applied.

the thing come import script file via script tag importing it doesn't run inside script.

how do that?

thanks

if understund correct, have create script file contentlike

generate script on server:

// approch totally differt, because not let user generate script on server, answer question ... function executerule(){ // name of function rulename , must unique   document.getelementyid("withrules").innhtml = document.getelementyid("withrules").innhtml.replace('[userenteredvalue1]','[userenteredvalue2]'); } 

//this code should executed when radiobutton selected

and add script per html - script - tag

<script src="/generated_user_script.js"></script> <!-- line per generated script --> 

and on select(the onchange/onclick event, when checked attribute set) call function, quick dirty. :) if have many rules need uniqe names, dont override themselfes , on.

this said other approche javascript code not create better. if replace function, may store input , output values or so.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -