Avatar of mustish1
mustish1

asked on 

Day of the week

How to use a day of the week in a text box without using any script
<input type="text" name="DayOfTheWeek">

Thanks
Web Languages and Standards

Avatar of undefined
Last Comment
Gary
Avatar of Gary
Gary
Flag of Ireland image

You can't, you need a server side language or javascript
Avatar of mustish1
mustish1

ASKER

Can I write it down inside the tag without calling any function something like

<input type="text" name="DayOfTheWeek" value="javascript.dateDay()">

Thanks
Avatar of Gary
Gary
Flag of Ireland image

No it would have to be a separate function outside the input.
Avatar of mustish1
mustish1

ASKER

document.javascript.DayOfTheWeek

Something like that
Avatar of Gary
Gary
Flag of Ireland image

There is no such thing as the name of a day in javascript - you have to create it yourself
And you cannot have javascript in an input that will fire automatically

http://jsfiddle.net/TM5Gk/

<input type="text" name="DayOfTheWeek" id="dayofweek" value="">
<script>
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
now = new Date();
day = now.getDay();

document.getElementById("dayofweek").value=weekday[day];
</script>

Open in new window

Avatar of mustish1
mustish1

ASKER

I dont know what i made mistake its not showing in it

<html>
<head>
<title>Test Day</title>
<script>
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
now = new Date();
day = now.getDay();
document.getElementById("dayofweek").value=weekday[day];
</script>
</head>
<p><h3>Week Day</h3> </p>
<form method = "Post" action = "">
<p><label>Week Day<input name = "mDayoftheweek" type ="text" id="dayofweek"></label></p>
<input type = "submit" value = "Submit">
<input type = "submit" value = "Clear">
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Gary
Gary
Flag of Ireland image

But this is preferable
<html>
<head>
<title>Test Day</title>

</head>
<body>
<p><h3>Week Day</h3> </p>
<form method = "Post" action = "">
<p><label>Week Day<input name = "mDayoftheweek" type ="text" id="dayofweek"></label></p>
<input type = "submit" value = "Submit">
<input type = "submit" value = "Clear">
</form>
<script>
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
now = new Date();
day = now.getDay();
document.getElementById("dayofweek").value=weekday[day];
</script>
</body>
</html> 

Open in new window

Avatar of mustish1
mustish1

ASKER

Thanks Cathal
Avatar of Gary
Gary
Flag of Ireland image

np
Web Languages and Standards
Web Languages and Standards

Web development can range from developing the simplest static single page of plain text to the most complex web-based internet applications, electronic businesses, and social network services using a wide variety of languages and standards, including the familiar HTML, JavaScript and jQuery, ASP and ASP.NET, PHP, ColdFusion, CSS, PHP, Flex and Flash, but also the implementation of a broad list of standards including XML, WSDL, SSDL, VoiceXML and many more.

40K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo