<form name="form"><textarea name="message"></textarea>
<img src="" onmousedown="(do the prompt box)">
</form>
i need help how to figure out how to prompt the user with a javascript prompt() to enter a url(link) that includes an http://
after the user enters the url in the prompt box and clicks OK, i want the textarea to add the following to were the mouse cursor/carat was at:
<a href="(the link that the user submitted)">(the link that the user submited)</a>
the only code i found that does anything relavent is this one:
<img onmousedown="addTags('[link]','[/link]')" src="ajax/addlink.png" border="0">
and this JS function adds the tags(bbcode thing)
function addTags(Tag,fTag,Message)
{
var obj = document.form.message;
obj.focus();
if (document.selection && document.selection.createRange) // Internet Explorer
{
sel = document.selection.createRange();
if (sel.parentElement() == obj) sel.text = Tag + sel.text + fTag;
}
else if (typeof(obj) != "undefined") // Firefox
{
var longueur = parseInt(obj.value.length);
var selStart = obj.selectionStart;
var selEnd = obj.selectionEnd;
obj.value = obj.value.substring(0,selStart) + Tag + obj.value.substring(selStart,selEnd) + fTag + obj.value.substring(selEnd,longueur);
}
else obj.value += Tag + fTag;
obj.focus();
}
where the cursor is, and if text is highlighted it keeps that text and ads the bbcodes around it. but this is not what i want. i want the textarea to have the html link with the users imputted url two times like i stated above.
i have very little expirince with javascript and like none with prompt();
i dont even know how to get the usersinput.