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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.