September 10, 2010, 08:00:12 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Always search the forum before posting !
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Redirect to form with parameter  (Read 1170 times)
Guni
Newbie

Offline Offline

Posts: 7


« on: August 31, 2009, 06:02:40 pm »

Hello guys,

I will open a specific form by clicking on a button.
Which form is gonna be opened depends on the constellation of some select lists.
To open these forms I use this code and it works great.
Code:
ff_redirectParent('{mossite}/index.php?option=com_facileforms'+
            '&ff_name=PW_input'+
            '&Itemid=-1');

But now I want to pass some parameters from the 1st Form to the second form.
How can i do this. Can this be done by the function I use at the moment?

I would appreciate your information.
« Last Edit: August 31, 2009, 07:14:35 pm by Guni » Logged
andrewvanmarle
Administrator
Full Member
*****
Offline Offline

Posts: 169



« Reply #1 on: August 31, 2009, 06:27:25 pm »



Like this:
Code:
$identity=ff_getSubmit('identity');
header("Location: {mossite}/index.php?option=com_facileforms&ff_name=formname&ff_param_identity=$identity&ff_page=1");

I get in this code the param from the element called identity, and pass it ass the param named identity.

You can easily add both the get submit and the passing of the param (&ff_param_identity=$identity) to your own code.

You use a different way of writing it, so I'll let you tinker with it  instead of giving you an incorrect example Smiley
Logged

Andrew

Please read the forum rules first!
Please do not use PM for generic questions!
Question regarding breezing forms? read this
Guni
Newbie

Offline Offline

Posts: 7


« Reply #2 on: August 31, 2009, 09:18:24 pm »

Thanks very much Andrew.
I tried it with your example, but unfortunately it doesn't work.
I think it would work if I submit the form to a database.
But I don't submit anything on the 1st Form. My 'Next' button
should only open a new form with some parameters from textfields or Select lists from the 1st one.

Code:
function mainFunction(pw)
{
if(pw==2)
{
$test=ff_getSubmit('pw');
//var test = ff_getElementByName('textfield').value  This would nice if it would work. But I know that this is not possible :-(
 ff_redirectParent('{mossite}/index.php?option=com_facileforms&ff_name=PW_input&ff_param_test=$test&Itemid=-1');
}

In the Initialization Script of the 2nd Form, I've got this code
Code:
ff_getElementByName('newtextfield').value = $test


I hope there are no big errors in my logic :-/
« Last Edit: August 31, 2009, 09:29:20 pm by Guni » Logged
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1359



« Reply #3 on: September 01, 2009, 12:06:24 am »

Hi Guni
This will work for you...
Code:
ff_redirectParent('
{mossite}/index.php?option=com_facileforms&ff_name=PW_input&Itemid=-1&ff_param_test='+escape(ff_getElementByName('name of your select list').value)+'
');

Dont forget you need to pick up the value of the parameter somthing like this...
Code:
<?php
//retrieve param
$x ff_getParam('ff_param_test');
return 
"$x";
?>


hth
« Last Edit: September 01, 2009, 12:16:26 am by boldee » Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
Guni
Newbie

Offline Offline

Posts: 7


« Reply #4 on: September 01, 2009, 04:03:29 pm »

Thanks very much boldee!

After I wrote your statement in one line the Javascript code is executed without any errors
and the new form shows up.  Smiley
I also wrote this custom php code in the Before Form/Form Pieces section of the 2nd form.
Code:
<?php
//retrieve param
$x ff_getParam('ff_param_test');
return 
"$x";
?>

In the Initialization Script section I wrote the following:
Code:
function ff_PW_input_init()
{

ff_getElementByName("QEC_Code").value = $x;
} // ff_PW_input_init

But that doesn't work.
The Firefox error console says: $x not defined

Now my question is, how can I make $x available in the JS code?
Logged
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1359



« Reply #5 on: September 01, 2009, 07:06:58 pm »

If you make $x a global variable...
Code:
<?php
//set globals
global $x;

//retrieve param
$x ff_getParam('ff_param_test');
return 
"$x";
?>


If then becomes available in js as below...
Code:
var xyz =  '<?php global $x; return $x?>';

hth
Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
Guni
Newbie

Offline Offline

Posts: 7


« Reply #6 on: September 01, 2009, 09:52:38 pm »

Oh my god, it works  Shocked
Thank you so much guys!
Boldee, you're code is great. I just had to add the loading of the initLib to the php code.
Finally I can see the parameter in a textfield of the new form.

There is only one little mistake now. The parameter also shows up in the upper left corner
of the form.
How can I avoid that?


Thanks again  Grin
Logged
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1359



« Reply #7 on: September 01, 2009, 11:34:03 pm »

Get rid of the return $x in the parameter code.
Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF © 2001-2006 Lewis Media
| Terms of Use | Privacy | Sitemap |