473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Insert code only link into textarea

23
This should be very simple.
It is NOT a live link!
I have no idea how to do this, so need some help please.

Expand|Select|Wrap|Line Numbers
  1. <form>
  2. <input type="button" id="link" value="Link"><br>
  3. <textarea name="message" style="width:40%; height:100px;">
  4. <a href="http://domain.com">Name</a>
  5. </textarea><br>
  6. <input type="submit" value="Save">
  7. </form>
  8.  
The object is to:
1 Click the Link button.
2 Enter URL into 1st prompt
3 Enter Name into 2nd prompt
4 The HTML will show in the textarea (like above)
5 Save does all the rest elsewhere.

I reckon this will probably not be more than 1k of JavaScript.

Hope someone can help - thanks in advance.
Nov 1 '18 #1
5 1769
Luuk
1,047 Expert 1GB
In your scenario, I think point 2 and 3 should go before point 1. Its' much easier to first input the data you need, and by clicking on the link start to do something with that data.

About point 4: I think it's not possible to show HTML of an external site in a textarea.

You should use IFRAME for that purpose.
Nov 4 '18 #2
Roamer
23
Thanks

HTML in a textarea is standard for editors. The code gets parsed when processed.
Nov 14 '18 #3
Luuk
1,047 Expert 1GB
OK, I was bored, so I googled for the answer I did not know, and hers is the output:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <script>
  5.  
  6.         // https://stackoverflow.com/questions/10642289/return-html-content-as-a-string-given-url-javascript-function
  7.         function httpGet(theUrl) {
  8.             if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
  9.                 xmlhttp = new XMLHttpRequest();
  10.             }
  11.             else {// code for IE6, IE5
  12.                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  13.             }
  14.             xmlhttp.onreadystatechange = function () {
  15.                 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  16.                     document.getElementById('returnText').value = xmlhttp.responseText;
  17.                     //returnText.value = "TESTTEXT";
  18.                     //return "TESTTEXT";
  19.                     //return xmlhttp.responseText;
  20.                 }
  21.             }
  22.             xmlhttp.open("GET", theUrl, false);
  23.             xmlhttp.send();
  24.         }
  25.  
  26.  
  27.         function dostuff() {
  28.             var link = document.getElementById('textlink');
  29.             alert('dostuff:' + link.value);
  30.             httpGet(link.value);
  31.  
  32.         }
  33.  
  34.     </script>
  35. </head>
  36. <body>
  37.     <input type="button" id="link" value="Link" onclick="dostuff()"><br>
  38. <textarea id='textlink'>http://domain.com</textarea>
  39.     <form onsubmit="dostuff()">
  40.         <input type="button" id="link" value="Link" onsubmit="dostuff()"><br>
  41. <textarea name="message" id="returnText" style="width:40%; height:100px;">
  42. <a href="http://domain.com">Name</a>
  43. <h1>TEST-H1</h1>
  44. </textarea><br>
  45.         <input type="submit" value="Save">
  46.     </form>
  47.     <p>You might get an error described on this page: https://techsupport.osisoft.com/Documentation/PI-Web-API/help/topics/cross-origin-resource-sharing.html</p>
  48. </body>
  49. </html>
Nov 15 '18 #4
Can you do it vice versa? Maybe it will help?
Nov 16 '18 #5
Luuk
1,047 Expert 1GB
"vice versa"?, you mean putting the (html-)code back on the server?

That will be pretty useless. A properly configured server will not allow that (to be done from a remote location).

Also a lot of servers use logic to create HTML-pages, like PHP, NodeJS, .ASP . If that's the case, than it will be even more useless to put code back to the server.
Nov 16 '18 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Gordan | last post by:
Hi i would like to insert some text in textarea at the current cursor position (not on the end of txtarea (not value+=something)) any ideas? :-) Gordan
6
by: Max | last post by:
i want to insert a predefined string in a textarea when i right click on the mouse. i need to do it in internet explorer and mozilla.
4
by: Sergio del Amo | last post by:
i, I have the next html page <html> <head> <script> <!-- function insertcode() { var code ="<p> blablabal babala babababab</p><h1>here comes header</h1><span>fadfafa<a...
3
by: Islam Elkhayat | last post by:
Hello everybody Ihave few .CSS files, I let user select the color schema of the whole site using a radiobutton and save it in a cookie.. I want to retrieve the value of the cookie <link href=" ...
2
by: Mano kumar | last post by:
hello guys, i'm having a very strange problem, this is a simple insert code. andthe insert stmt has NO problem cos i've tried it on my access table. and heres the error msg Operation must use...
4
by: TristaSD | last post by:
Hi, I'm trying to figure out how to INSERT/UPDATE text from TEXAREA into MySQL. Because TEXAREA has no VALUE, I'm hitting a brick wall here. Thanks!
15
by: globalrev | last post by:
i have a translator-program for the robbers language. i want the user to input into the topwindow and then display the encryption or decryption in the bottom window. i am currently trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.