java prompt to insert link into textarea

T

TonnyD

I need to use a prompt to insert links into a text area in frontpage
to allow it to be user friendly. I have come up with the following
script which i have pieced together from other discussions. The only
problem is I cant get it to work. I was able to stop all the errors
but now the information will not post in the text area. Im definitely
new with this and I am not sure what to do next.


<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.form1.short_story.value += '<a href="'+url+'">'+label+'</a>';
}
</script>
<form action="add.php" name="form1" 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>
 
T

TonnyD

Hello,

Change


(remove the duplicate id value)

--
Singapore Website Designhttp://www.bootstrike.com/Webdesign/
Singapore Web Hostinghttp://www.bootstrike.com/WinXP/faq.html
Windows XP FAQ







- Show quoted text -

That worked Well Thanks.

Also is there any way to allow for 2 prompts? For example two buttons
that do different thing. I have one for links as you know, but i also
want to do one for images. I have the script working, but both buttons
are only working for one script (IE only inserting links) Is there a
way to differentiate which button will run which script. I will post
the two scripts below.



************************************1*****************************************
<script language="JavaScript">
function insertUrl()
{
var url = prompt("Enter the complete URL for the image. Be sure the
Image is at most 400 x 400 or it will be to large and not posted",
'http://');


document.FrontPage_Form1.comment.value += '<image src="'+url+'">';
}
</script>



<input type="button" value="Click to Insert Link"
onClick="insertUrl()">


*********************************************2**********************************************




<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.FrontPage_Form1.Response.value += '<a href="'+url+'">'+label
+'</a>';
}
</script>

<input type="button" value="Click to Insert Link"
onClick="insertUrl()">
 
T

TonnyD

Hello,

Change


(remove the duplicate id value)

--
Singapore Website Designhttp://www.bootstrike.com/Webdesign/
Singapore Web Hostinghttp://www.bootstrike.com/WinXP/faq.html
Windows XP FAQ







- Show quoted text -

That worked Well Thanks.

Also is there any way to allow for 2 prompts? For example two buttons
that do different thing. I have one for links as you know, but i also
want to do one for images. I have the script working, but both buttons
are only working for one script (IE only insurting links) Is there a
way to differentiate which button will run which script. I will post
the two scripts below.



************************************1*****************************************
<script language="JavaScript">
function insertUrl()
{
var url = prompt("Enter the complete URL for the image. Be sure the
Image is at most 400 x 400 or it will be to large and not posted",
'http://');


document.FrontPage_Form1.comment.value += '<image src="'+url+'">';
}
</script>



<input type="button" value="Click to Insert Link"
onClick="insertUrl()">


*********************************************2**********************************************




<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.FrontPage_Form1.Response.value += '<a href="'+url+'">'+label
+'</a>';
}
</script>

<input type="button" value="Click to Insert Link"
onClick="insertUrl()">
 
T

TonnyD

That worked Well Thanks.

Also is there any way to allow for 2 prompts? For example two buttons
that do different thing. I have one for links as you know, but i also
want to do one for images. I have the script working, but both buttons
are only working for one script (IE only insurting links) Is there a
way to differentiate which button will run which script. I will post
the two scripts below.

************************************1**************************************­***
<script language="JavaScript">
function insertUrl()
{
var url = prompt("Enter the complete URL for the image. Be sure the
Image is at most 400 x 400 or it will be to large and not posted",
'http://');

document.FrontPage_Form1.comment.value += '<image src="'+url+'">';}

</script>

<input type="button" value="Click to Insert Link"
onClick="insertUrl()">

*********************************************2*****************************­*****************

<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.FrontPage_Form1.Response.value += '<a href="'+url+'">'+label
+'</a>';}

</script>

<input type="button" value="Click to Insert Link"
onClick="insertUrl()">- Hide quoted text -

- Show quoted text -

thanks allot worked like a charme.
 
S

SingaporeWebDesign

Hello,

You're welcome.

--
Singapore Website Design
http://www.bootstrike.com/Webdesign/
Singapore Web Hosting
http://www.bootstrike.com/WinXP/faq.html
Windows XP FAQ

That worked Well Thanks.

Also is there any way to allow for 2 prompts? For example two buttons
that do different thing. I have one for links as you know, but i also
want to do one for images. I have the script working, but both buttons
are only working for one script (IE only insurting links) Is there a
way to differentiate which button will run which script. I will post
the two scripts below.

************************************1**************************************­***
<script language="JavaScript">
function insertUrl()
{
var url = prompt("Enter the complete URL for the image. Be sure the
Image is at most 400 x 400 or it will be to large and not posted",
'http://');

document.FrontPage_Form1.comment.value += '<image src="'+url+'">';}

</script>

<input type="button" value="Click to Insert Link"
onClick="insertUrl()">

*********************************************2*****************************­*****************

<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.FrontPage_Form1.Response.value += '<a href="'+url+'">'+label
+'</a>';}

</script>

<input type="button" value="Click to Insert Link"
onClick="insertUrl()">- Hide quoted text -

- Show quoted text -

thanks allot worked like a charme.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top