Jump to content

Load Css/js File To Textbox From A Link


gromstone

Recommended Posts

I am looking for suggestions and code samples to get a file and load it into a text area. Let me give a bit more of a detail.

 

My code searches for a file, and with in that file there is a array for additional CSS files. I am looking for a way to get the CSS file to be loaded to a text-area once you click on a button.

 

Every file contains this:

$CSS = array(file.css);

 

Now, how can I get:

<a href="file.css">CSS</a>

 

or

<button onclick="myFunction()">CSS</button>

 

To load here:

<textarea id="filecontent" name="filecontent" cols="80" rows="10">".$filecontent."</textarea>

Link to comment
https://forums.phpfreaks.com/topic/270456-load-cssjs-file-to-textbox-from-a-link/
Share on other sites

If you don't want the page to reload, you'll need to use some javascript to make an ajax request. It would go something like this:

 

On click, make an ajax request to a php file with the "href" of the link

In the PHP file, open the requested file and read the contents.

Return the requested array, which the ajax handler will be listening for

Update the text area with the return.

 

Sound like what you're looking for?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.