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:
- http://music-dump.com/id/00000
http://youtube-id.com/download/00000
etc.
i want generate list of new hyperlinks "00000" replaced userinput. list should generate button click or on-the-fly user typing. far found 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); }); }
Comments
Post a Comment