This topic is locked

Pre filled form for add new values on the fly

10/17/2012 8:54:25 AM
PHPRunner General questions
C
christoph30 author

Hello,
I have a table with seven fields for each day where user names are stored and with additional seven fields after each day where the user can add hours for each day.

Those hours will be saved into another table.

Therefore I added a lockup wizard for each of the seven possible days and selected the option "Allow free input" and "Allow to add new values on the fly"

I also pre-filled the add form with some session values. This is working.

No the problem: The pre filled session values are depending on the day.

So my only question is: I need something like a indicator or session value which I can ask for in a if clause for which day the "add new values on the fly" function is active.

Or I have to know which "add field" the user just clicked on - something like a caller. If I know the caller (maybe the field for monday) than I can ask for and pre fill.
Have someone an idea?
Thanks.

Regards,

Chris

C
cgphp 10/17/2012

Chris, could you post some screenshots to better illustrate your request?

C
christoph30 author 10/17/2012



Chris, could you post some screenshots to better illustrate your request?


Hello,
to make it clear:
Table contains the fields:
monday, monday_hours, tuesday, tuesday_hours, wednesday, wednesday_hours, etc...
example data entry:
mike, 5, mike, 6, jane, 1, etc...
So now I have in monday_hours, tuesday_hours etc. a lockup wizard with the add new values on the fly function, because the table hours contains later the name, which is in monday or tuesday etc., the value which is in monday_hours, tuesday_hours etc. and some other values, like the date which I save with the now() function.
So the only think what I need now:
If someone click on the add link on the field: tuesday_hours, I have to pre-fill the name from the field tuesday.

This is working already with monday (session variables), but not with other days, because I am locking for an indicator where I know: Ok so the user just clicked on the tuesday_hours add link and not on the monday_hours add link.
Regards,

Chris

C
christoph30 author 10/19/2012

Hello Christian,
do you have an idea, what could be the indicator?
Regards,

Chris

C
christoph30 author 10/24/2012

Hello,
no one has an idea?
Regards,

Chris

Sergey Kornilov admin 10/25/2012

Chris,
you need to rephrase your question or better yet provide a couple of screenshot that would explain what you trying to build.

C
christoph30 author 10/25/2012



Chris,
you need to rephrase your question or better yet provide a couple of screenshot that would explain what you trying to build.


ok I rephrase, because screenshots would be German and maybe not understandable.
There is a list. On this list I activated inline edit.

If the user hit edit on an entry in the list there are 7 different "add on the fly" fields (lockup wizard or another table)

The only thing what I want to know: How can I know in the php coding, which of the 7 "add on the fly" fields the user clicked on?

There must something like a id or value where I can ask for.

C
christoph30 author 10/30/2012

no on has an idea?

I guess it is super simple but now one used the add on the fly function and wanted to know which of the different add on the fly fields the user clicked on to do something on the time of clicking?

Sergey Kornilov admin 10/30/2012

Sorry, it just doesn't make much sense to me being explained this way.

C
christoph30 author 11/1/2012

Ok, here is your own example:
http://xlinesoft.com/livedemo/phprunner/livedemo3/orders_edit.php?editid1=10248
There you have Add new at the field Customer

So imagine there is also a Add new at the field Employee
So, how can I know, wheather the user click on the Add new next of the Customer field or next of the Employee if I want to know this because I need this in a event?
And this is exactly what I explained already.
There is a field monday and monday hours , thuesday and tuesday hours and so on. And I just want to know how I know wheather the user click the add new on the monday hours or tuesday hours.
By the way: I cannot add screenshots, there comes a message: You are not allowed to use that image extension on this board, but you can see it here: http://imm.io/K0RE

C
cgphp 11/1/2012

In the "Javascript onload" event, enter the following code:

$("a[id^='addnew_value_FIRSTFIELDNAME']").click(function(e){

//enter here your custom code

});
$("a[id^='addnew_value_SECONDFIELDNAME']").click(function(e){

//enter here your custom code

});


Replace FIRSTFIELDNAME and SECONDFIELDNAME with the real names of your fields (the name of the fields near the "Add new" link).

C
christoph30 author 11/2/2012



In the "Javascript onload" event, enter the following code:

$("a[id^='addnew_value_FIRSTFIELDNAME']").click(function(e){

//enter here your custom code

});
$("a[id^='addnew_value_SECONDFIELDNAME']").click(function(e){

//enter here your custom code

});


Replace FIRSTFIELDNAME and SECONDFIELDNAME with the real names of your fields (the name of the fields near the "Add new" link).


Thanks for the answer.
I change your example to this one.

But the session variable is not filled.

I am not sure how to combine PHP and Javascript:
$("a[id^='addnew_value_monday_hours']").click(function(e){
$_SESSION["monday_hours"] = 'X';
});
$("a[id^='addnew_value_tuesday_hours']").click(function(e){
$_SESSION["tuesday_hours"] = 'X';
});

C
christoph30 author 11/5/2012

Hello,
have anybody an idea how to fill a session variable in the coding example?
Regards,

Chris

C
cgphp 11/5/2012

In the Javascript code you can't add php statements. You need an ajax call to set a session var. You can find more info here: http://api.jquery.com/jQuery.ajax/

C
christoph30 author 11/5/2012



In the Javascript code you can't add php statements. You need an ajax call to set a session var. You can find more info here: http://api.jquery.com/jQuery.ajax/


Is there no easy way just to set in a session variable a 'X' if the user click on the "add new" (on the fly)?

In this ajax call (I never used something like this):

how is the coding to say: $_SESSION["tuesday_hours"] = 'X';?
I have to set something like an indicator, since I have to ask for in the add form.

C
christoph30 author 11/10/2012

Hello,
I have no idea how to set the session variable, depending on the "add new values" click.

Javascript on load seems not to work.

Is there another possibility?
Chris

Sergey Kornilov admin 11/10/2012

In the Javascript code you can't add php statements. You need an ajax call to set a session var. You can find more info here: http://api.jquery.com/jQuery.ajax/
You need to create a new PHP file outside of PHPRunner and execute an AJAX request to this file. In this PHP file you can set the session variable.