database-fields <--> new fields

hi,
using SC6.
maybe this is a problem which is correspondenting with this: http://www.scriptcase.net/forum/showthread.php?5087-OnChange-trigger-hide-show-and-vuelue-updates-bug-or-am-i-too-stupid

I just made a test.

Database:

ID (ai) INT
TEST1 TXT
TEST2 TXT

Form:
(all database fields)

  • add “TEST3”

Ajax:
Test1 on click

sc_ajax_message({Test2}, {Test3});

Result:
When I insert a value in TEST2 and TEST3 and than click into TEST1, a message is given:
No title (its just blanc)
message: TEST3 (the value I inserted)

so… is this normal? i never noticed. is there a difference in acting with new fields, which arent in the database?
or does “my scriptcase” just behaves strange? I just did install it new on a local machine, because my home-SC chrasched.

No imho this is expected to occur. Ajax events happen on the client side and you are displaying data from the server side. When you have inserted data into field 2 and field 3 then this data resides locally as there has not been any submit to the server. When you click on the onclick ajax event that this is not a submit of the other fields. So imho you need to set ajaxevents on the other fields to make sure that they are available on the server side. Haven’t tested it, but it might be that you need some globals here:

onchange field1
[glob_field1]={field1};

onchange field 2
[glob_field2]={field2};

as these are php variables the data of the form will be transferred to the server.
At least… I think.

thank you.

i broke it down to an easier problem:

the fields are updated correctly.
BUT if you use any variable, which isnt declared, it does not update any field in the ajax-script any longer.

look:

ajax on change:

if ({contactname}=="")
{
{contactname}=“here is nothing”;

}

// sc_ajax_message({contactname}, $asny);

works. if you delete the entry of contactname-field and change focus, than there is a new antry “there is nothing”.

BUT

if ({contactname}=="")
{
{contactname}=“here is nothing”;

}

sc_ajax_message({contactname}, $asny);

notice that message-macro isnt longer commentary.
notice also that $asny doesnt exist.

result is, that the field is updated right, but this isnt shown in the form.

if ({contactname}=="")
{
{contactname}=“here is nothing”;

}
$asny=“hurra”;
sc_ajax_message({contactname}, $asny);

works again.

you can test this. i made an new account an SC-testpage.
v7.scriptcase.net/scriptcase_en/devel/iface/login.php
login: test
pass: test

there is a form. look at ajax_onchange.

How? Thanks …

[SIZE=1]Edit: Hab es gefunden … ;-).[/SIZE]

I’m missing the point. If I delete the text it gets the right value. If I enter something this is shown in the ajax message and is stored in the database, I set debug on and the pdo statement is correct.

[QUOTE=RHS;19024]How? Thanks …

[SIZE=1]Edit: Hab es gefunden … ;-).[/SIZE][/QUOTE]

Ok, wo? Ich hab’s noch nicht gefunden…

http://www.scriptcase.net/scriptcase-demo-online/

ok, sorry for speaking without explanation. i see this is not understandable.

forget the first post in this thread. I didnt worte down ALL of the code. I did let out something which - as I thought - had nothing to do with the problem.

the second posting is the base of the problem:

when you write something into a field,
firing the onchange-event,
than change by code the value of another field (or even the same field)
than everything is ok.

BUT

if you have a unset variable in the code, even if it is something complete different, and there is a variable used whithout beeing set up,
then NO value in the form will change.

p.e.

you have in the code the variable $one.
you set up $one
( $one=“eins”; )

and use it all around.

THAN at one part of the script you make a misstake and spell it wrong:

if ($onne == “eins”)
{…

you have a new variable: onne whch is never been used before and which has no value of course.
THAN
something like {field1}=“here we are” will not work anymore. try it in the test-account.

[QUOTE=RHS;19024]

[SIZE=1]Edit: Hab es gefunden … ;-).[/SIZE][/QUOTE]

g guuuuut :slight_smile: