Solved

default date value in input box

Posted on 2010-11-10
9
304 Views
Last Modified: 2012-08-13
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
<form action="<?php echo $SCRIPT_NAME ?>" method="get">

Date:

<input size="10" type="text" name="today" value=<?PHP echo $today;?>>&nbsp;</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>

Open in new window

0
Comment
Question by:Henk_du_Toit
  • 5
  • 4
9 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34105856
Try something like this:

<input size="10" type="text" name="today" value="<?php echo date('r'); ?>" />
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34105866
The ways of handling date and time strings are described in this article.  You may find it helpful.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

Best regards, ~Ray
0
 

Author Comment

by:Henk_du_Toit
ID: 34105978
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.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34106031
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.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Henk_du_Toit
ID: 34106075
Attached is the code for the date and the query that uses the date.

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;?>>&nbsp;</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);

?>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34106163
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.
0
 

Author Comment

by:Henk_du_Toit
ID: 34106202
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..
0
 

Accepted Solution

by:
Henk_du_Toit earned 0 total points
ID: 34106442
I have fixed it. Thanks for your help anyway..

Attached is what I did to fix it
global $today;



if (isSet($_GET['today'])) {



$today	= $_GET['today'];

} else {

$today	= date('d-M-Y');

}

Open in new window

0
 

Author Closing Comment

by:Henk_du_Toit
ID: 34134703
I have found a solution myself.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now