/    Sign up×
Community /Pin to ProfileBookmark

Help Needed, please help me

Hello,
I am searching to find a script can insert hyperlink into textarea but have not recieved yet any good result.
Once, the search result was this thread in this forum:
[url]http://www.webdeveloper.com/forum/s…ad.php?t=109274[/url]
it was just what I needed but I could not use it in my script. because it promps well, but dose not insert the url given into textarea.
now I have included the html part of my page in which the javascript must function :

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html”>
<title>title</title>
</head>
<script language=”JavaScript”>
function insertUrl()
{
var url = prompt(“Enter the complete URL for the hyperlink”, ‘http://’);
var label = prompt(“Enter the title of the website”, “website”);
if (url && label)
document.short_story.value += ‘<a href=”‘+url+'”>’+label+'</a>’;
}
</script>
<form action=”add.php” name=”guest” method=”POST” onsubmit=”return check_fields()”>
<textarea name=”short_story” rows=”4″ cols=”95″ style=”font-family: Tahoma; font-size: 8pt; font-weight:bold”>
</textarea>
<input type=”button” id=short_story value=”Click to Insert Link” onClick=”insertUrl()”>
<input type=”hidden” name=”dosend” value=”yes”>
</table>
</form>
</br>
</body>
</html>

Now I ask any body could help me by changing that promp script so that it can insert hyperlink into textarea,id”short_story” and the result of insert should be :
<a target=”_blank” href=”url”>Link Title</a>

[U]This is what I found in this forum:[/U]
<script language=”JavaScript”>
function insertUrl()
{
var url = prompt(“Enter the complete URL for the hyperlink”, ‘http://’);
var label = prompt(“Enter the title of the website”, “website”);
if (url && label)
document.short_story.value += ‘<a href=”‘+url+'”>’+label+'</a>’;
}
</script>

[U]This is my textarea where the urls should be insert:[/U]
<textarea name=”short_story” rows=”4″ cols=”95″ style=”font-family: Tahoma; font-size: 8pt; font-weight:bold”>
</textarea>

[U]and this is the buton to call it :[/U]
<input type=”button” id=short_story value=”Click to Insert Link” onClick=”insertUrl()”>

…………..
Anybody could help me? Your help would be apreciated as I do not know scripts, but I have lost my time on this and my site is off!
Thanks a lot.
waiting for help.
regards,
afx

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Jul 24.2006 — Reference to a form element should be

document.forms[0].elementName.value

or

docment.formName.elementName.value

or

docment.getElementById("formId").elementName.value

or

docment.getElementById("elementId").value

Eric
Copy linkTweet thisAlerts:
@afxbackauthorJul 24.2006 — Thank you dear A1ien51!

worked well

Great Help!!

again and gain thanks!
×

Success!

Help @afxback spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...