button - javascript to open form and select records

Status
Not open for further replies.

susannanam

Member
hi all,

here is what i would like to realize:
i have a form and added a button element. when clicking, i would like to open a form where i can select records which shall then be imported into the table and show in the initial form.

i have some ideas like:
- somehow open a popup with the form (js? no idea how to do t hat)
- in the list i put a prefilter to have the correct data and a checkbox element to select the rows
- a php plugin to get the selected rows (how?) and copy them over to the initial table
- refresh the initial form (how?)

...but dont really know yet how to get this together and most of all, i have no js knowledge :((( anyone with a hint please?

thanks
susanna
 
hi all,

here is what i would like to realize:
i have a form and added a button element. when clicking, i would like to open a form where i can select records which shall then be imported into the table and show in the initial form.

i have some ideas like:
- somehow open a popup with the form (js? no idea how to do t hat)
- in the list i put a prefilter to have the correct data and a checkbox element to select the rows
- a php plugin to get the selected rows (how?) and copy them over to the initial table
- refresh the initial form (how?)

...but dont really know yet how to get this together and most of all, i have no js knowledge :((( anyone with a hint please?

thanks
susanna

here is an update:
when saving the form, i now save an app variable:
Code:
$app = JFactory::getApplication();
echo"student no = " . $studentno;
//exit;
$app->input->set('my_student_id', $studentno);
$app->input->set('my_inv_no', $inv_no);

the button element has the following javascript (it works but not yet perfect as it shows the toolbar, etc and the link is still the admin one but it SHOWS :)))):
Code:
window.open('http://www.nets-box.edu.na/administrator/index.php?option=com_fabrik&task=list.view&listid=152','Select courses to invoices','width=400,height=200');

the list that opens has a pre-filter where i want to use the variable 'my_student_id'. the list opens, no error but the prefilter does not work... i have tried a few things but i cant get it right. how can i access the app-variable please? here is the prefilter:
Code:
$app = JFactory::getApplication();
$app->output->('my_student_id');
type = eval

thanks for any hint :)
susanne
 
What informatoin are you trying to get and fill in from the other tables? Is it just the PK, so you can set a join, or do you need to grab other data to prefill fields on your form?

Have you looked ae the autofill form plugin? That will only do one selection at a time, but I think you could put it in a repeat group.

-- hugh
 
What informatoin are you trying to get and fill in from the other tables? Is it just the PK, so you can set a join, or do you need to grab other data to prefill fields on your form?

Have you looked ae the autofill form plugin? That will only do one selection at a time, but I think you could put it in a repeat group.

-- hugh

Hi Hugh,

unfortunately it is not the int pk that i need to grab and also the autofill would not work in my case. but i come along quite good so far, i just dont know yet how to implement the app variable into the prefilter of the form. do you have any hint for me please?

susanne
 
As mentioned in another thread, I can't log in to your site, none of the passwords I have for you are working.

And I'm still really not clear on what you are trying to do, so we're going to have to get together on Skype and you show me what you are trying to do, and walk me through what you have so far.

-- hugh
 
Hi Hugh

as just discussed on skype, the account is usually disabled. will enable it and wait for you on skype :)

basically i want to use an application variable in another list prefilter. is that possible?

susanne
 
thanks troester for your answer and sorry for my delay, i was struggeling :(

i tried a few things but cant get it right, currently i have this version:
$app = JFactory::getApplication();
$student=$app->input->get('my_student_id');
var_dump($student);exit;
return my_student_id;

my problem is, i dont know if the variable my_student_id is filled correctly out of the $app and it just does not work to use it as pre-filter or if it is not coming correctly out of the $app :( the current output of $student is NULL. well if it does not work, i might need to do a workaround and save the value in a table. what is your opinion?
 
Try with cookies
$app = JFactory::getApplication();
echo"student no = " . $studentno;
//exit;
$app->input->cookie->set('my_student_id', $studentno);

and in the prefilter
$app = JFactory::getApplication();
$student=$app->input->cookie->get('my_student_id');
 
it also gives NULL :(

i checked again the $studentno and that one shows the correct student number. so either the setting into the cookie or the getting is a problem :(((
 
It's working on my site:
form php (onBeforeStore), you can test get directly after set
Code:
$inputCookie  = JFactory::getApplication()->input->cookie;
$myid = '{$my->id}';
$inputCookie->set('my_student_id', $myid);
//$x = $inputCookie->get('my_student_id');
//var_dump($x);
//exit;
list prefilter
Code:
$inputCookie  = JFactory::getApplication()->input->cookie;
$y= $inputCookie->get('my_student_id');
var_dump($y);
exit;
 
Hi again... sorry for the long silence, we first finished another part and had training on the site :) now i am back on that one and have to finish it...

if i have the above code directly in the same form, like setting and getting it, it also works perfectly on my side. if i have the setting in the one form and the getting as pre-filter in the list i call by the button, then it gives NULL as result. maybe getting a cookie as part of the pre-filter is not possible?
 
That's probably the cookie path, which is typically very server dependent. Default is for PHP to set it to the "current path" of page. So because your list URL is a different path, it's not available from there.

So you may need to set a cookie path, and do it with the vanilla PHP setcookie(), getcookie(), so when setting the cookie ...

Code:
setcookie('my_student_id', $myid, time()+3600, '/');

This should make the cookie available anywhere, by using '/' as the path, and you should then be able to read it back with the code you already have. Set the time to whatever you want - the time()+3600 sets the lifetime to one hour ... time now + 3600 seconds.

-- hugh
 
Note that cookies can be problematic, as quite a few people disable them. You may also be required by law to disclose that you store cookies, although I have no clue what the law is in your neck of the woods (or desert, or whatever you have out there).

Another alternative might be to store it in the session. There's quite a few examples in the forums of doing this, searching for session->get should find some.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top