So, as you can see the "<?php echo $quote; ?>" inside the TEXTAREA tag. I wish, when users click the QUOTE button, the quotet post will appear in the textarea, using $_GET.
The path to the server side file (PHP I presume) that will generate the external content that you want to load.
This is what you said
Quote:
I wish, when users click the QUOTE button, the quotet post will appear in the textarea, using $_GET.
$_GET is a PHP array. To have this you'll need to make a request (usually Ajax request) to your server side script and output something for the browser to show.
The path to the server side file (PHP I presume) that will generate the external content that you want to load.
This is what you said
$_GET is a PHP array. To have this you'll need to make a request (usually Ajax request) to your server side script and output something for the browser to show.
Alright. The PATH is not the problem then, as the #replyText textarea is in the PATH which I entered.
$(document).ready(function(){
$("#butto a").colorbox({width:"30%", inline:true, href:"#inline_example1"});
$('.example99').colorbox(function(){
// replyText is the id of the textarea
$('#replyText').load('PATH');
});
});
But now, it just opens the ColorBox BUT inside the ColorBox, is the entire PATH. Not just the #replyText
1. In your first code example you bound the colorbox to an element with id 'example8', which was not at all visible in your HTML code
2. In your last code example you changed that to a link AND an element with id example99 all of a sudden
3. Where is the element with id 'replayText' located? Is it inside the current HTML (the same page where the Javascript code is running)? Or is it in an external PHP file that you want to load?
4. What do you want to achieve with .load('PATH') ? You need to replace PATH by the actual physical path to the PHP file you want to execute server side ... of course depending upon what your answer to (3) is
If you are using a JavaScript library (such as, presumably, JQuery) why don't you say that from the very first line? And name it; for all of us to know from the beginning what are we talking about. There are tens of JavaScript libraries, and we are not suppose to know all of them by hard, are we?
If you are using a JavaScript library (such as, presumably, JQuery) why don't you say that from the very first line? And name it; for all of us to know from the beginning what are we talking about. There are tens of JavaScript libraries, and we are not suppose to know all of them by hard, are we?
Sorry about that. Yes, I am using jQuery.
I am sorry, but I easily get very confused with all of this code.
I think I have a slight idea about what your problem MIGHT be ... because there are a lot of people out there that have problems with that
So I give you a short outline of the general client/server architecture with PHP/HTML/Javascript
Browser request
1. You enter a URL into the address bar. Let's say it's going to an index.php with a single parameter index.php?value=5
2. The server will receive the request, look for index.php and execute it (if found). The parameter will then be available inside the PHP script as $_GET["value"]
3. The script will output some "stuff". Usually this is HTML (plus Javascript). The web server sends the output to the browser. The PHP script terminates(!)
4. The browser engine reads the response from the server and builds an internal representation as a tree ... the so called DOM. The rendering engine traverses the tree and renders all the elements. They become visible (if set to "visible" of course) in the browser
5. Javascript code that is embedded into the server response or has to be read from an external source will be executed (sometimes immediately, sometimes only after some user interaction).
6. Sometimes the Javascript code wants to load additional external content. It does that by initiating a request to a server side script. It's mostly the same as in (1), but it happens in the "background" without the browser refreshing the page. This is called an AJAX request. Now steps (2) and (3) execute mostly the same way as before.
7. The output of the script will be available for Javascript on the current page (still without any page refresh). So it's still the code from (5) that is running. The response from the new script can now be embedded into the existing DOM. So it will be made visible.
PHP and Javascript are not "directly" connected. You can neither read PHP variables from Javascript nor Javascript variables from PHP without sending and receiving requests!
I think I have a slight idea about what your problem MIGHT be ... because there are a lot of people out there that have problems with that
So I give you a short outline of the general client/server architecture with PHP/HTML/Javascript
Browser request
1. You enter a URL into the address bar. Let's say it's going to an index.php with a single parameter index.php?value=5
2. The server will receive the request, look for index.php and execute it (if found). The parameter will then be available inside the PHP script as $_GET["value"]
3. The script will output some "stuff". Usually this is HTML (plus Javascript). The web server sends the output to the browser. The PHP script terminates(!)
4. The browser engine reads the response from the server and builds an internal representation as a tree ... the so called DOM. The rendering engine traverses the tree and renders all the elements. They become visible (if set to "visible" of course) in the browser
5. Javascript code that is embedded into the server response or has to be read from an external source will be executed (sometimes immediately, sometimes only after some user interaction).
6. Sometimes the Javascript code wants to load additional external content. It does that by initiating a request to a server side script. It's mostly the same as in (1), but it happens in the "background" without the browser refreshing the page. This is called an AJAX request. Now steps (2) and (3) execute mostly the same way as before.
7. The output of the script will be available for Javascript on the current page (still without any page refresh). So it's still the code from (5) that is running. The response from the new script can now be embedded into the existing DOM. So it will be made visible.
PHP and Javascript are not "directly" connected. You can neither read PHP variables from Javascript nor Javascript variables from PHP without sending and receiving requests!
Arh. That actually makes sense. Thanks a lot! I understand how AJAX works now.
Although, I still can't seem to work on my page. So, I will start from scratch:
I see an error on the slyfox's approach regarding the TEXTAREA element. Despite the general belief, the TEXTAREA element has no innerHTML. Same as all the form's elements, a TEXTAREA has a value attribute/property, thus the value has to be read/write, in a way or another (using only PHP or AJAX)
I see an error on the slyfox's approach regarding the TEXTAREA element. Despite the general belief, the TEXTAREA element has no innerHTML. Same as all the form's elements, a TEXTAREA has a value attribute/property, thus the value has to be read/write, in a way or another (using only PHP or AJAX)
So what do I need to do? Please refer to my post above.
Well yes. But a textarea tag do not have a VALUE attr. So:
Code:
<textarea><?php echo $quote; ?></textarea>
But that is not the problem; the problem is to get the $quote text INSIDE the textarea, when clicking on a link. (The TEXTAREA is placed in the ColorBox lightbox)