Passing variables

Page: 1

Author Post
pmaonline
Guest
Hi, how can i pass a value from an input box to floatbox?

i have something like this:

// contains values
<input type="text" name="tot" onclick="get_check_value()">

<input type="submit" name="print" value="print" onclick="fb.loadAnchor('pdf/print.php',' width:650 height:428 caption:`Printing`');return false;"/>


Thanks
Administrator
Registered: Aug 2008
Posts: 3382
You'll find it's easier to pass data from the floatboxed content down to the parent than it is to pass it up to a box, but it's not bad going up either.

There's a sample on the demo page that does just this. Check out the "Talkin' to an iFrame" sample on the code tab, and take a look at the source of that. The basic idea is that from the floatboxed content you run parent.document.getElementById to fetch an element from the base page and either read or write data to/from it.

To go the other way, to push or fetch data from the boxed content from code running on the base page, you would want to first get the floatboxed iframe's document element. You can do this with fb.getIframeDocument(fb.fbContent) as described in the API reference.

And finally, if the floatbox content is not an iframe (i.e., it's ajax or inline), then you only have one document involved and you can put ids on the elements of interest and fetch them from anywhere with document.getElementById.
pmaonline
Guest
Thanks for the answer. I did as you told me and i sucessfully passed the values to the floatbox but i need that values in a php array.

So in the mainpage i have an input with values: "100,101,102,103" and these numbers are ids and when i onpen the file print.php with floatbox i need to execute a query with this ids...

I need this to act like a POST. Is it possible ?

Thanks
Administrator
Registered: Aug 2008
Posts: 3382
It sounds like your challenge is not passing information to or from a floatbox, but rather from your forms to your php backend. Floatbox has nothing to do with that conversation. It neither assists nor impedes the operations of your forms. It just puts some decoration around them.

It's usually a good idea to get your forms and back-end stuff working the way you want without floatbox in the picture, and after that's all built and debugged, then load the forms up into floatbox.

If a post is unsuitable for some reason, you may want to try communicating with your server-side code via an ajax get. AJAX, posting, however your application coordinates client-side and server-side data exchange, it's oustide the scope of floatbox support and entirely in the realm of your application's design and build.
pmaonline
Guest
Thanks ... i got a solution. It's here:


<script>
function get_check_value()
{
var c_value = "";
for (var i=0; i < document.frm.check.length; i++)
{
if (document.frm.check.checked)
{
c_value = c_value + "," + document.frm.check.value + "\n";
document.frm.tot.value = c_value;
}
}
}
</script>

<input type="checkbox" name="check" value="<?=$SQL->f('id')?>" onclick="get_check_value();"/>

<input type="hidden" name="tot" id="tot" />

<a href="#" onclick="get_check_value(); fb.loadAnchor('pdf/print.php?id='+tot.value,' width:650 height:428 caption:`Printing multiple orders`');return false;"/>
<img src="images/icons/print.gif" border="0"> Print Orders</a>

FILE print.php
<?php
print_r($_GET);
?>
$id = substr($_GET['id'],1);
include "../includes/db.php";
opendb();
$sql = "SELECT * FROM orders WHERE id IN ($id)";
$result = mysql_query($sql);
while($myrow = mysql_fetch_array($result))
{
..........
}

:D

Page: 1