3 frames problem
Moderator: General Moderators
3 frames problem
hi.
i have a page that consists of 3 frames, the second and third frames contain radio buttons, the top frame contain a button, i want to be able to access the values of the radio buttons once I click on the button on the first frame, i want to use PHP because i will be forming a Query based on these radio buttons. any Ideas?????? THANKS in advance.
i have a page that consists of 3 frames, the second and third frames contain radio buttons, the top frame contain a button, i want to be able to access the values of the radio buttons once I click on the button on the first frame, i want to use PHP because i will be forming a Query based on these radio buttons. any Ideas?????? THANKS in advance.
using php to access the variables across frames will be difficult as they (all pages (frames)) have to be sent to the server in order for php to handle the variables.
your best bet would be to just access the variables with JS across the frames.
something like:
untested
your best bet would be to just access the variables with JS across the frames.
something like:
untested
Code: Select all
<!-- this is frame one -->
<script>
function getFrameTwoVal()
{
document.getElementById("frametwoval").value = top.frametwoname.getElementById("frametwovar").value;
}
</script>
<input type="hidden" name="frametwoval" id="frametwoval">
<input type="button" onClick="getFrameTwoVal()" value="get value">
<!-- this is frame two -->
<input type="text" name="frametwovar" id="frametwovar">- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
A combination of JavaScript and PHP.
When a value is selected in the radio boxes, make the frame that you're building the query in redirect to http://current_url.tld/?somevalue=something then read the value from $_GET.
Alternatively, have the user submit the form by clicking a button and put the target attribute in the <form> tag so that the data goes to the other frame.
When a value is selected in the radio boxes, make the frame that you're building the query in redirect to http://current_url.tld/?somevalue=something then read the value from $_GET.
Alternatively, have the user submit the form by clicking a button and put the target attribute in the <form> tag so that the data goes to the other frame.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It's a common question... and one that doesn't have a neat answer.
because JS runs on the client side and php on the server it's not simple.
One way, slightly Old skool is to do something like:
Then in the PHP code you would get that variable like so:
The most modern methodlogy uses AJAX, but if you're new to all this it might be beyond you right now.
Check out http://xajax.sourceforge.net to learn more about ajax though
because JS runs on the client side and php on the server it's not simple.
One way, slightly Old skool is to do something like:
Code: Select all
var some_js_var = 'somevalue_to_pass_to_php';
if (some_event_happens) window.location = 'thisphpfile.php?some_var=' + some_js_var; //RedirectCode: Select all
$some_var_from_js = (isset($_GET['some_var']) ? $_GET['some_var'] : FALSE);
echo $some_var;Check out http://xajax.sourceforge.net to learn more about ajax though
ok Burrito,
now lets sumarize the whole thing,
when i click on the buttom on the first frame, you want me to activate a JS function that gets the 2 radio buttons on the second and third frames. fine, i can do that, then i need the same action (CLICK) to send these variables to a PHP file for processing, can i call a PHP file from within a JS function?
or am I missunderstanding you?
now lets sumarize the whole thing,
when i click on the buttom on the first frame, you want me to activate a JS function that gets the 2 radio buttons on the second and third frames. fine, i can do that, then i need the same action (CLICK) to send these variables to a PHP file for processing, can i call a PHP file from within a JS function?
or am I missunderstanding you?
indeed you can with AJAX or XMLHttp.
It's really one in the same, AJAX actually uses the XMLHttp object but includes a much larger library.
if you look at my tutorial it will walk you through making a http request (via post or get) to another page where you can send variable information to the server without changing the page or reloading the current page.
It's really one in the same, AJAX actually uses the XMLHttp object but includes a much larger library.
if you look at my tutorial it will walk you through making a http request (via post or get) to another page where you can send variable information to the server without changing the page or reloading the current page.