javascript - How can I generate a list of modified hyperlinks based on user input -


i'm trying modify list of urls using either html or javascript. collected list of sites embed youtube video. this:

<script type="text/javascript">  function changetext2(){      var userinput = document.getelementbyid('userinput').value;      var lnk = document.getelementbyid('lnk');      lnk.href = "http://music-dump.com/id/" + userinput;      lnk.innerhtml = lnk.href;   }  </script>
type youtube code , click open! <a href="" id=lnk>link</a> <br>  <input type='text' id='userinput' value='' />  <input type='submit' onclick='changetext2()' value='open'/>

but generate 1 link. want huge list. possible?

is want?

type youtube code , click open!  <div id="links"> </div> <input type='text' id='userinput' value='' /> <input type='submit' onclick='changetext2()' value='open'/> 

and javascript:

var links = [     "http://music-dump.com/id/00000",     "http://youtube-id.com/download/00000",     "http://example.com/v/00000" ];  function changetext2() {     var userinput = document.getelementbyid('userinput').value;      links.foreach(function(link) {         link = link.replace("00000", userinput);         var = document.createelement("a");         a.href = link;         a.innerhtml = link;         document.getelementbyid('links').appendchild(a);     }); } 

http://jsfiddle.net/u7hfuagw/2/


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -