Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Hide input html code (for hyperlinks) in textarea

Posted on 2005-04-09
12
Medium Priority
?
644 Views
Last Modified: 2012-06-21
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 :)
0
Comment
Question by:fgict
  • 7
  • 5
12 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13744004
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
 
LVL 1

Author Comment

by:fgict
ID: 13744024
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13744052
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:fgict
ID: 13744059
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13744064
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
 
LVL 1

Author Comment

by:fgict
ID: 13744071
yes i would imagine doing a replace keywords against their hyperlink values in list before saving them would be possible in asp..somehow..
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 2000 total points
ID: 13744080
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
 
LVL 1

Author Comment

by:fgict
ID: 13744107
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13744137
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13744284
So, how is this working?

FtB
0
 
LVL 1

Author Comment

by:fgict
ID: 13744288
Sorry.. still working on it.. have to get back to you after w/e if that is ok
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13744340
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Integration Management Part 2
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question