Hide input html code (for hyperlinks) in textarea

I have a need to hide input html code (for hyperlinks) in textarea field so that the only data that a user can input into the textarea is either plain text or select a hyperlink from a dropdown list above the textarea. I do not wish to post the code like:
(the <a href="www.test.com">Test</a> website.) I just wish the end user to see (the Test website) in the textarea code with "Test" word as a hyperlink.

I do not wish to turn the textarea into a full editor either. The Code at present is like..

<body bgcolor="#FFFFFF" text="#000000">
<select name="hyperlinks">
  <option value="">Select a Link</option>
  <option value="http://www.test1.com">Test1</option>
  <option value="http://www.test2.com">Test2</option>
</select>
<form name="form1">
  <textarea cols="50" rows="10" name="message"></textarea></form>
</body>

Be grateful for any assistance :)
LVL 1
fgictAsked:
Who is Participating?
 
fritz_the_blankConnect With a Mentor Commented:
Okay, how is this to start?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<script language="JavaScript">
<!--
function addLink(intSelected){
      var objForm = document.forms['form1']
      strLink = objForm.elements['hyperlinks'].options[intSelected].text;
      objForm.elements['message'].value +=strLink;

}
//-->
</script>
</head>

<body>
<form name="form1">
      <select name="hyperlinks" onChange="addLink(this.selectedIndex)">
        <option value="">Select a Link</option>
        <option value="http://www.test1.com">Test1</option>
        <option value="http://www.test2.com">Test2</option>
      </select><br>
  <textarea cols="50" rows="10" name="message"></textarea>
 
  </form>

</body>
</html>
0
 
fritz_the_blankCommented:
I don't understand the question. Let's break it down:

1) if the user selects an item from the select list, the display text (not the value) should appear in the text area
2) the user should be able to type the display text (not an actual URL) into the text area

Is this much correct? Also, can the user type anything else into the text area, i.e., some text that is not present as the display text of your select list?

FtB
0
 
fgictAuthor Commented:
Hi FtB

Points 1 & 2 are correct.
I only wish to allow the user type text into the textarea box.. and to input a hyperlink they must select a from dropdown list to populate the textarea box. Hope this explains my problem alittle better.

fgict
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
fritz_the_blankCommented:
I am afraid it doesn't. Let me ask this another way--what if the user wants to type the word "Cow" into the text area. Is that allowed?

FtB
0
 
fgictAuthor Commented:
ok..

Yes every text is basically allowed in textarea field.. but when user wants to create a hyperlink they should choose this from the dropdown menu.
The textarea field will not show e.g. <a href="http://www.test.com>Test</a> but it will only show word Test (but the hyperlink code will be saved to database from textarea when user clicks "Submit" button)

:)
0
 
fritz_the_blankCommented:
Okay, I get it now. This is sort of possible, but what will have to happen is that when the user submits the form, we will have to replace the text Test1 Test2 and etc. with the actual URLs. Perhaps we can even do this server-side?

FtB
0
 
fgictAuthor Commented:
yes i would imagine doing a replace keywords against their hyperlink values in list before saving them would be possible in asp..somehow..
0
 
fgictAuthor Commented:
ok it's populating the Link name.. now we need to populate the link name and value as hyperlink.. then conceal it in textarea so it only shows link name..
0
 
fritz_the_blankCommented:
No no no!!! That is what we discussed above! You will have to grab the name and do a replace with server-side code once the form is submitted, i.e."

strMessage = Request.Form("message")

strMessage = Replace(strMessage, "Test1", "<a href ='http://www.test1.com'>Test1</a>")
strMessage = Replace(strMessage, "Test2", "<a href ='http://www.test2.com'>Test2</a>")

FtB
0
 
fritz_the_blankCommented:
So, how is this working?

FtB
0
 
fgictAuthor Commented:
Sorry.. still working on it.. have to get back to you after w/e if that is ok
0
 
fritz_the_blankCommented:
That's fine. I just wanted to make sure that you had everything you needed as I won't be around so much.

Good luck!

FtB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.