Henk_du_Toit
asked on
default date value in input box
Hi,
I have a querie that you can update after putting the date in the input box. Is there a way to put today's date by default in this box, but be able to change the date to a different date to override todays date?
Cheers
I have a querie that you can update after putting the date in the input box. Is there a way to put today's date by default in this box, but be able to change the date to a different date to override todays date?
Cheers
<form action="<?php echo $SCRIPT_NAME ?>" method="get">
Date:
<input size="10" type="text" name="today" value=<?PHP echo $today;?>> </input>
<A HREF="#" onClick="cal1x.select(document.forms[0].today,'anchor1x','dd-NNN-yyyy'); return false;" TITLE="Today" NAME="today" ID="anchor1x">
<IMG SRC="images/cal.JPG"></A>
<button value="Update" type="submit">Update</button>
</form>
The ways of handling date and time strings are described in this article. You may find it helpful.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
Best regards, ~Ray
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
Best regards, ~Ray
ASKER
Hi Ray,
Thanks for your post. I know how to put today's date in by default. The only thing I am having trouble with is overriding when you change it on the web page.
<input size="10" type="text" name="today" value="<?php echo date('d-M-Y'); ?>" />
Doing this brings the default date like I want, but when I change the date to say last week on the web page, the value displayed stays as todays date.
Thanks for your post. I know how to put today's date in by default. The only thing I am having trouble with is overriding when you change it on the web page.
<input size="10" type="text" name="today" value="<?php echo date('d-M-Y'); ?>" />
Doing this brings the default date like I want, but when I change the date to say last week on the web page, the value displayed stays as todays date.
Can you please post a more complete example of your code? I think I can show you how to use a PHP variable to carry this information to the right places.
ASKER
Attached is the code for the date and the query that uses the date.
Is this more or less what you wanted?
Is this more or less what you wanted?
<SCRIPT LANGUAGE="JavaScript" ID="jscal1x">
var cal1x = new CalendarPopup("testdiv1");
cal1x.setCssPrefix("TEST");
cal1x.showNavigationDropdowns();
</SCRIPT>
<form action="<?php echo $SCRIPT_NAME ?>" method="get">
Date:
<input size="10" type="text" name="today" value=<?PHP echo $datum;?>> </input>
<A HREF="#" onClick="cal1x.select(document.forms[0].today,'anchor1x','dd-NNN-yyyy'); return false;" TITLE="Today" NAME="today" ID="anchor1x">
<IMG SRC="images/cal.JPG"></A>
<button value="Update" type="submit">Update</button>
</form>
<?php
$cmdstrnw="select crep,brand,sum(gsales),sum(disc),sum(invsales),sum(pof),subtotalgsales,subtotaldisc,subtotalinvsales,subtotalpof,budget,subtotalbudget,crep1 from
(select a.crep as crep,a.brand as brand,
nvl(e.gsales,0) + nvl(b.gsales,0) + nvl(c.sale,0) as gsales,
nvl(e.disc,0) + nvl(b.disc,0) as disc,
nvl(e.invsales,0) + nvl(b.invsales,0) + nvl(c.sale,0) as invsales,
nvl(e.invsales,0) + nvl(b.invsales,0) + nvl(c.sale,0) - nvl(e.disc,0) - nvl(b.disc,0) - nvl(e.cogs,0) - nvl(b.cogs,0) as pof,
sum(nvl(e.gsales,0) + nvl(b.gsales,0) + nvl(c.sale,0)) over(partition by a.crep) as subtotalgsales,
sum(nvl(e.disc,0) + nvl(b.disc,0)) over(partition by a.crep) as subtotaldisc,
sum(nvl(e.invsales,0) + nvl(b.invsales,0) + nvl(c.sale,0)) over(partition by a.crep) as subtotalinvsales,
sum(nvl(e.invsales,0) + nvl(b.invsales,0) + nvl(c.sale,0) - nvl(e.disc,0) - nvl(b.disc,0) - nvl(e.cogs,0) - nvl(b.cogs,0)) over(partition by a.crep) as subtotalpof,
nvl(d.budget,0) as budget,
sum(nvl(d.budget,0)) over(partition by a.crep) as subtotalbudget,
a.crep1
from
(select a.nama as crep,a.brand as brand1,a.dsca as brand,a.crep as crep1
from brandl a) a
left join
(select crep,brand,sum(gsales) as gsales,sum(disc) as disc,sum(invsales) as invsales,sum(cogs) as cogs from(
select e.t\$nama as crep,
case when d.t\$cbrn = 'RETAIL' then d.t\$cbrn else brand.brand end as brand,
sum(b.t\$damt/b.t\$rats$1) + sum(b.t\$amld/b.t\$rats$1) as gsales,
sum(b.t\$amld/b.t\$rats$1) as disc,
sum(b.t\$damt/b.t\$rats$1) as invsales,
sum(b.t\$copr$1/b.t\$rats$1) as cogs
from twhinh200099 a, ttdsls401099 b, twhinh220099 c, ttccom110099 d, ttccom001099 e, brand, ttcibd001099 f
where a.t\$orno = b.t\$orno
and a.t\$orno = c.t\$orno
and d.t\$ofbp = a.t\$stco
and e.t\$emno = d.t\$crep
and b.t\$pono = c.t\$pono
and a.t\$oset = c.t\$oset
and f.t\$item = b.t\$item
and f.t\$cpcl = brand.cpcl
and b.t\$dltp <> '1'
and b.t\$clyn <> '1'
and d.t\$crep in ('NO','SO','CE','60','CON')
and to_date(c.t\$addt + 0.54167) between to_date('$startw 00:00:00') and to_date('$today 23:59:59')
group by e.t\$nama,d.t\$cbrn,brand.brand)
group by crep,brand) e
on a.crep = e.crep
and a.brand1 = e.brand
left join
(select crep,brand,sum(gsales) as gsales,sum(disc) as disc,sum(invsales) as invsales,sum(cogs) as cogs from(
select e.t\$nama as crep,
case when d.t\$cbrn = 'RETAIL' then d.t\$cbrn else brand.brand end as brand,
sum(a.t\$damt/a.t\$rats$1) + sum(a.t\$amld/a.t\$rats$1) as gsales,
sum(a.t\$amld/a.t\$rats$1) as disc,
sum(a.t\$damt/a.t\$rats$1) as invsales,
sum(a.t\$copr$1/a.t\$rats$1) as cogs
from ttdsls401099 a, twhinh210099 b,twhinh200099 c,ttccom110099 d, ttccom001099 e,brand, ttcibd001099 f
where a.t\$orno = b.t\$orno
and a.t\$orno = c.t\$orno
and d.t\$ofbp = c.t\$sfco
and e.t\$emno = d.t\$crep
and b.t\$pono = a.t\$pono
and b.t\$oset = c.t\$oset
and f.t\$item = a.t\$item
and f.t\$cpcl = brand.cpcl
and a.t\$dltp <> '1'
and a.t\$clyn <> '1'
and d.t\$crep in ('NO','SO','CE','60','CON')
and to_date(b.t\$prdt + 0.54167) between to_date('$startw 00:00:00') and to_date('$today 23:59:59')
group by e.t\$nama,d.t\$cbrn,brand.brand)
group by crep, brand) b
on a.crep = b.crep
and a.brand1 = b.brand
left join
(select crep,brand,sum(sale) as sale from(
select
ttccom001099.t\$nama as crep,
case when ttccom110099.t\$cbrn = 'RETAIL' then ttccom110099.t\$cbrn else brand.brand end as brand,
sum(tcisli225099.t\$amth$1/tcisli225099.t\$rate$1) as sale
from tcisli225099, tcisli220099,ttcibd001099,ttccom100099, ttccom110099, brand, ttccom001099
where tcisli225099.t\$item not like '%REBATE%'
and tcisli225099.t\$item not like '%PROMO%'
and tcisli225099.t\$item not like '%ZZ-1%'
and tcisli225099.t\$item not like '%ZZ-5%'
and tcisli225099.t\$item not like '%ZZ-6%'
and tcisli225099.t\$sfcp = tcisli220099.t\$sfcp
and tcisli225099.t\$msid = tcisli220099.t\$msid
and tcisli225099.t\$item = ttcibd001099.t\$item
and tcisli220099.t\$itbp = ttccom100099.t\$bpid
and tcisli220099.t\$ofbp = ttccom110099.t\$ofbp
and ttccom001099.t\$emno = ttccom110099.t\$crep
and ttcibd001099.t\$cpcl = brand.cpcl
and ttccom100099.t\$bpid = ttccom110099.t\$ofbp
and ttccom110099.t\$crep in ('NO','SO','CE','60','CON')
and to_date(tcisli220099.t\$date + 0.54167) between to_date('$startw 00:00:00') and to_date('$today 23:59:59')
group by brand.brand,ttccom110099.t\$cbrn,ttccom001099.t\$nama)
group by crep,brand)c
on c.crep = a.crep
and c.brand = a.brand1
left join
(select crep,brand,sum(budget) as budget from (
select b.t\$nama as crep,
case when a.cata = 'C' then 'Branded' else 'Unbranded' end as brand,
sum(a.budget) as budget
from budgets a, ttccom001099 b
where year = (SELECT CASE
WHEN TO_DATE('$startw 23:59:59') BETWEEN TO_DATE('$starty 00:00:00') AND add_months(TO_DATE('$endy 23:59:59'),-3)
THEN TO_NUMBER(TO_CHAR(TO_DATE('$startw 23:59:59'),'YYYY'))+ 1
ELSE TO_NUMBER(TO_CHAR(TO_DATE('$startw 23:59:59'),'YYYY')) END AS jaar FROM DUAL)
and a.rep in ('NO','SO','CE','60','CON')
and a.monnum = (SELECT CASE
WHEN TO_DATE('$startw 23:59:59') BETWEEN TO_DATE('$starty 00:00:00') AND add_months(TO_DATE('$endy 23:59:59'),-3)
THEN TO_NUMBER(TO_CHAR(TO_DATE('$startw 23:59:59'),'MM'))-3
ELSE TO_NUMBER(TO_CHAR(TO_DATE('$startw 23:59:59'),'MM'))+9 END AS jaar FROM DUAL)
and a.rep = b.t\$emno
group by b.t\$nama, a.cata)
group by crep,brand) d
on d.crep = a.crep
and d.brand = a.brand)
where (gsales <> 0
or budget <> 0)
group by crep,crep1,brand,subtotalgsales,subtotaldisc,subtotalinvsales,subtotalpof,subtotalbudget,budget
order by crep,brand
";
$parsednw=ociparse($db_conn, $cmdstrnw);
ociexecute ($parsednw);
$nrowsnw=ocifetchstatement($parsednw, $resultsnw);
?>
I'm not following this. In the code you posted, $datum is an undefined variable. You will get a Notice or a NULL value in the <input> control named "today".
You might also want to put quotes around the string in the value= attribute of the input tag.
You might also want to put quotes around the string in the value= attribute of the input tag.
ASKER
Sorry I was playing around with it... $datum should be $today. It works perfectly, the only thing I want to achieve is to bring today's date up by default and be able to change it to any other date with that date being the new value of the input box..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have found a solution myself.
<input size="10" type="text" name="today" value="<?php echo date('r'); ?>" />