Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Change date

Post Reply
CoCiX
Posts: 6
Joined: Sun Mar 11, 2012 10:59 pm

Change date

Unread post by CoCiX »

Hi,
i have two fields,loan_type and member_type, that i take the values from a database and another field with date.
When i choose the values from that field which are specific i want to change the date
for example in sql i would write it something like that
SELECT CURRENT_DATE + INTERVAL
CASE WHEN membership_type = 'staff'
AND Loan_type = 'short' THEN 10
WHEN membership_type = 'staff'
AND Loan_type = 'long' THEN 20
WHEN membership_type = 'student'
AND Loan_type = 'short' THEN 30
WHEN membership_type = 'student'
AND Loan_type = 'long' THEN 40 END DAY

how can i do that in nubuilder? with php or javascript?
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Change date

Unread post by admin »

CoCiX,

Do you know php and javascript?

Steven
CoCiX
Posts: 6
Joined: Sun Mar 11, 2012 10:59 pm

Re: Change date

Unread post by CoCiX »

Hey,
yes but i am not expert i tried this one but it is not working
var first = 6;
var second = 12;
var third = 18;
var forth = 24;

var fi = (document.getElementById("due_date");


fi = new Date();
lo = document.getElementById("loan_type").value;
mem = document.getElementById("mem_type").value;
if(lo = 1 && mem = 1)
{
fi.setDate(fi.getDate() + first);
alert(fi);
}
else if(lo = 2 && mem = 1)
{
fi.setDate(fi.getDate() + second);
alert(fi);
}
else if((lo = 1 && mem = 2)
{
fi.setDate(fi.getDate() + third);
alert(fi);
}
else
fi.setDate(fi.getDate() + forth);
alert(fi);
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Change date

Unread post by admin »

CoCiX,

You have at least 2 places where you have an opening bracket without a closing bracket and one place where you set fi to an HTML object and then to a date.

I suggest you write 1 or 2 lines at a time and get that working, or put alert()s or nuDebug()s http://wiki.nubuilder.com/tiki-index.ph ... g_pString_ through your code to see where things break.

This forum is really about nuBuilder and how PHP and JavaScript work with it.

For general help with PHP and JavaScript you really need to look elsewhere.

Steven
Post Reply