I am looking everywhere for the most basic way to take a text area, have a text link that says "Add Link" clcikt he link, a box pops up asking for website url, then you click ok, then it popsup asking for title, you clcik ok, it then creates an html text link, not bbcode but a real html link with this with a class="bluelinkbold' added to the link as well, any help greatly appreciated
The most basic method is something like: You will need to change the enter the... words, the FORMNAME and fieldname. <script> function CreateLink(){ var iurl = prompt("ENTER THE URL OR DIE", ""); var ititle = prompt("ENTER THE TITLE OR DIE", ""); document.forms["FORMNAME"].fieldname.value "<a href=\""+iurl+"\" class=\"bluelinkbold\">"+ititle+"</a>"; } </script> <form> <input type="button" value="ADD A LINK" onclick="CreateLink();"> </form> Code (markup):
Thanks for the reply, I tried this code below but it gives errors; <script> function CreateLink(){ var iurl = prompt("ENTER THE URL OR DIE", ""); var ititle = prompt("ENTER THE TITLE OR DIE", ""); document.forms["form1"].description.value "<a href=\""+iurl+"\" class=\"bluelinkbold\">"+ititle+"</a>"; } </script> <form name="form1" method="post"> <input type="button" value="ADD A LINK" onclick="CreateLink();"> <textarea name="description" cols="80" rows="4" id="description"></textarea> </form> PHP:
ooopss my fault, thats what I get when I edit the code AFTER I knew it was working. You need to change: document.forms[COLOR=#66CC66][[/COLOR][COLOR=#FF0000]"form1"[/COLOR][COLOR=#66CC66]][/COLOR].description.value [COLOR=#FF0000]"<a href=[COLOR=#000099][B]\"[/B][/COLOR]"[/COLOR]+iurl+[COLOR=#FF0000]"[COLOR=#000099][B]\"[/B][/COLOR] class=[COLOR=#000099][B]\"[/B][/COLOR]bluelinkbold[COLOR=#000099][B]\"[/B][/COLOR]>"[/COLOR]+ititle+[COLOR=#FF0000]"</a>"[/COLOR]; Code (markup): to document.forms[COLOR=#66CC66][[/COLOR][COLOR=#FF0000]"form1"[/COLOR][COLOR=#66CC66]][/COLOR].description.value [COLOR=#FF0000]= "<a href=[COLOR=#000099][B]\"[/B][/COLOR]"[/COLOR]+iurl+[COLOR=#FF0000]"[COLOR=#000099][B]\"[/B][/COLOR] class=[COLOR=#000099][B]\"[/B][/COLOR]bluelinkbold[COLOR=#000099][B]\"[/B][/COLOR]>"[/COLOR]+ititle+[COLOR=#FF0000]"</a>"[/COLOR]; Code (markup):
Hey thanks, that worked in firefox but didnt seem to work in IE, I found another code that worked in firefox and IE until I changed the bbcode to html, maybe you could change it to use html for me possible, heres the line function DoLink() { var link=prompt("Enter Link","http://"); if (link!=null) { insertAtCursor('textAREAname','[link=' + link + ']'); } } PHP: when I change bbcode for link to <a href=" " class="bluelinkbold">text<a/> it gives errors