Client-side Events: change keyup

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Client-side Events: change keyup

Post by mpol_ch »

Hi,

I am trying to get the Dayname from the field "Datum" for the field "Tag".
The field Datum is a Datepicker.
Can someone please advise what to check?

{ // keys = event types, values = handler functions
"change keyup": function(e) {
var $row = $(this).fields(); // Get an object of all fields, each property is a jQuery object of the input element(s) of a field
var seldate = $row["Datum"];
seldate = seldate.split('.');
var weekday=new Array();
weekday['Mon']="Monday";
weekday['Tue']="Tuesday";
weekday['Wed']="Wednesday";
weekday['Thu']="Thursday";
weekday['Fri']="Friday";
weekday['Sat']="Saturday";
weekday['Sun']="Sunday";
var dayOfWeek = weekday[seldate[0]];
$row["Tag"].value(seldate).readonly(true); // Set result to a field
}
}

thanks
mpol_ch


arbei
User
Posts: 9383

Post by arbei »

You code should be
$row["Tag"].value(dayOfWeek).readonly(true); // Set result to a field


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

thank you for your response.
I changed it.
Unfortunately it is still not working.
Could it be that the date format is causing the issue?
I am using this date format in datepicker dd.mm.YYYY.

thank you
mpol_ch


arbei
User
Posts: 9383

Post by arbei »

var dayOfWeek = weekday[seldate[0]];

User alert() or console.log() function to check seldate[0] is containing the correcting index. (e.g. Sun);

For example:
alert(seldate[0]);
var dayOfWeek = weekday[seldate[0]];


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

Hi arbei,

I am getting for the following code the alert "undefined".

{ // keys = event types, values = handler functions
"change keyup": function(e) {
var $row = $(this).fields(); // Get an object of all fields, each property is a jQuery object of the input element(s) of a field
var seldate = $(this).fields("Datum").value();
seldate = seldate.split(',');
var weekday=new Array();
weekday['Mon']="Monday";
weekday['Tue']="Tuesday";
weekday['Wed']="Wednesday";
weekday['Thu']="Thursday";
weekday['Fri']="Friday";
weekday['Sat']="Saturday";
weekday['Sun']="Sunday";
var dayOfWeek = weekday[seldate[0]];
alert(dayOfWeek);
}
}


arbei
User
Posts: 9383

Post by arbei »

The alert message said it is "undefined" means your cannot get the correct value in var dayOfWeek = weekday[seldate[0]];

Use alert() or console.log() function to check seldate[0] is containing the correcting index. (e.g. Sun);

Debug the variables again to make sure they are containing the correct value as you expected.


Post Reply