473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how can i insert a deafult value in an input text box?

for example if I have a box where you should put a date how do I keep
today date inside that box as default?

Jul 17 '05 #1
13 2731
You can do something like this, using the date function of PHP:
http://us3.php.net/date

$html = "<input type=\"text\" value=\"".date("m-d-Y")."\" />";

Jul 17 '05 #2

dsp...@gmail.com wrote:
You can do something like this, using the date function of PHP:
http://us3.php.net/date

$html = "<input type=\"text\" value=\"".date("m-d-Y")."\" />";


I would use single quotes here and avoid so many confusing
backslashes...

$html = '<input type="text" value="' . date("m-d-Y") . '" />';

I find this much easier to read.

Ken

Jul 17 '05 #3
"Ken Robinson" <ke******@rbnsn.com> wrote in news:1113401556.678161.246480
@l41g2000cwc.googlegroups.com:
I would use single quotes here and avoid so many confusing
backslashes...

$html = '<input type="text" value="' . date("m-d-Y") . '" />';

I find this much easier to read.


if we're on an "easier to read" tip, call me crazy, but I prefer to keep my
functions and variables kind of seperate. i'd make it into two lines:

$thedate = date("m-d-Y");
$html = "<input type=\"text\" value=\"$thedate\" />";

Jul 17 '05 #4
Good Man <he***@letsgo.com> wrote:
I would use single quotes here and avoid so many confusing
backslashes...

$html = '<input type="text" value="' . date("m-d-Y") . '" />';

I find this much easier to read.


if we're on an "easier to read" tip, call me crazy, but I prefer to keep my
functions and variables kind of seperate. i'd make it into two lines:

$thedate = date("m-d-Y");
$html = "<input type=\"text\" value=\"$thedate\" />";


With the "easier to read (and write)" (tm) version being:
$html = "<input type='text' value='$thedate' />";

Jul 17 '05 #5
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Daniel Tryba's handwriting:
Good Man <he***@letsgo.com> wrote:
I would use single quotes here and avoid so many confusing
backslashes...

$html = '<input type="text" value="' . date("m-d-Y") . '" />';

I find this much easier to read.


if we're on an "easier to read" tip, call me crazy, but I prefer to
keep my
functions and variables kind of seperate. i'd make it into two lines:

$thedate = date("m-d-Y");
$html = "<input type=\"text\" value=\"$thedate\" />";


With the "easier to read (and write)" (tm) version being:
$html = "<input type='text' value='$thedate' />";


And just to be annoying on this, I always capitalize the HTML tags,
therefore:
$thedate = date("m-d-Y");
$html = "<INPUT type='text' value='$thedate' />";
:)

Cheers
Mike
Jul 17 '05 #6
Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
With the "easier to read (and write)" (tm) version being:
$html = "<input type='text' value='$thedate' />";


And just to be annoying on this, I always capitalize the HTML tags,
therefore:
$thedate = date("m-d-Y");
$html = "<INPUT type='text' value='$thedate' />";
:)


It's an XHTML style element, and xhtml specs say:
http://www.w3.org/TR/xhtml1/#h-4.2

Jul 17 '05 #7
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Daniel Tryba's handwriting:
Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
With the "easier to read (and write)" (tm) version being:
$html = "<input type='text' value='$thedate' />";


And just to be annoying on this, I always capitalize the HTML tags,
therefore:
$thedate = date("m-d-Y");
$html = "<INPUT type='text' value='$thedate' />";
:)


It's an XHTML style element, and xhtml specs say:
http://www.w3.org/TR/xhtml1/#h-4.2


As I said: "I always capitalize HTML tags"
^^^^
and INPUT is also a HTML 4.xx element:
http://www.w3.org/TR/html4/interact/forms.html#h-17.4

Cheers
Mike
Jul 17 '05 #8
and my $.02
I believe the HTML spec requires values surrounded by "s not 's
and in general, my nictpick is to surround strings with 's so that PHP
won't parse them
so, I'll side with Ken's post above:

$thedate = date('m-d-Y');
$html = '<INPUT type="text" value="'.$thedate.'" />';

Jul 17 '05 #9
"BKDotCom" <bk***********@yahoo.com> wrote in news:1113414323.608892.170440
@l41g2000cwc.googlegroups.com:
and my $.02
I believe the HTML spec requires values surrounded by "s not 's
and in general, my nictpick is to surround strings with 's so that PHP
won't parse them
so, I'll side with Ken's post above:


but what are you doing with all your other variables? consistency is a
good thing... are your other variables really using single quotes like:

$name = 'Hank Azaria';
$address = '188 Burlington Road';

??

and if so, what happens when you have a name/address with an apostrophe
(ie: Mike O'Malley living at 87 O'Donell Avenue)? I thought it was good
form to use double-quotes in PHP just about *all* the time?
Jul 17 '05 #10
On 2005-04-13, Good Man <he***@letsgo.com> wrote:
and if so, what happens when you have a name/address with an apostrophe
(ie: Mike O'Malley living at 87 O'Donell Avenue)?
Then you escape it. What happens if you use a double-quoted string and
put a double-quote in it? Same thing.
I thought it was good form to use double-quotes in PHP just about
*all* the time?


Not really. Double-quotes means "evaluate me". Example in "Hello $world"
$world is evaluated. And also if you put in a newline or a tab it will
be "evaluated". Whereas single-quote means "do not evaluate me" so
variables and special characters like newline will not be evaluated.

Wether you use one or the other is primarily a matter of taste in the
cases where you don't use evaluation.

--
Cheers
- Jacob Atzen
Jul 17 '05 #11
Michał Woźniak wrote:
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Daniel Tryba's handwriting:

Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
With the "easier to read (and write)" (tm) version being:
$html = "<input type='text' value='$thedate' />";

And just to be annoying on this, I always capitalize the HTML tags,
therefore:
$thedate = date("m-d-Y");
$html = "<INPUT type='text' value='$thedate' />";
:)


It's an XHTML style element, and xhtml specs say:
http://www.w3.org/TR/xhtml1/#h-4.2

As I said: "I always capitalize HTML tags"
^^^^
and INPUT is also a HTML 4.xx element:
http://www.w3.org/TR/html4/interact/forms.html#h-17.4


Yes, but in that case you should write

"<INPUT type='text' value='$thedate'>"

rather than

"<INPUT type='text' value='$thedate' />"

right?

JP

--
Sorry, <de*****@cauce.org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Jul 17 '05 #12
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Jan Pieter Kunst's handwriting:
Micha³ Wo¼niak wrote:
One quick glance of an experienced eye allowed to understand the
blurred and almost unreadable Daniel Tryba's handwriting:

Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:

>With the "easier to read (and write)" (tm) version being:
>$html = "<input type='text' value='$thedate' />";

And just to be annoying on this, I always capitalize the HTML tags,
therefore:
$thedate = date("m-d-Y");
$html = "<INPUT type='text' value='$thedate' />";
:)

It's an XHTML style element, and xhtml specs say:
http://www.w3.org/TR/xhtml1/#h-4.2

As I said: "I always capitalize HTML tags"
^^^^
and INPUT is also a HTML 4.xx element:
http://www.w3.org/TR/html4/interact/forms.html#h-17.4


Yes, but in that case you should write

"<INPUT type='text' value='$thedate'>"

rather than

"<INPUT type='text' value='$thedate' />"

right?

JP


Ooops, missed that, thanks. :)

Cheers
Mike
Jul 17 '05 #13
BKDotCom <bk***********@yahoo.com> wrote:
I believe the HTML spec requires values surrounded by "s not 's


Nope, either is fine and may even be ommited in this case.
(http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2)

Jul 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tavish Muldoon | last post by:
What a pain trying to insert data into a table from a stored proc. My webform asks for 16 pieces of data - which then gets written to the database. I found this easier than the crap below...
12
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not...
1
by: solomon_13000 | last post by:
connection.asp: <% Sub RunQueryString (pSQL,parms) on error resume next Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &...
2
by: Tarik Monem | last post by:
OK! I've gone through a few tutorials and I cannot understand what I'm doing wrong casting_registration.php <table> <tr> <td> <form enctype="multipart/form-data" action="thankyou.php"...
1
by: bodilima | last post by:
Dear All, I'm new to this! I wanna insert selected values from form "SaveModel" to form "SaveMake" <input name="makeID" value="<<<<need to insert here(x)>>>>"> & <input name="make"...
7
by: annerhexian | last post by:
hi to all i am confused right now.. im just new in php.. and i have syntax error in my codes.. pls take a look? database name: ranking table: form1 fields: form1academicbachelor ...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
2
by: wizardry | last post by:
hello - i'm trying to insert a blob into my table, it will insert but the string that i insert when i query the inserted data returns null with 0 bytes in the column. I have other tables set...
7
by: tarunkhatri | last post by:
Hi, I want to insert multiple rows in a database table, from an submit form. But not able to trouble shoot the problem in my code. Following is the code. <form action=test_insert.php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.