Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Day of the week

Posted on 2014-01-10
10
Medium Priority
?
251 Views
Last Modified: 2014-01-11
How to use a day of the week in a text box without using any script
<input type="text" name="DayOfTheWeek">

Thanks
0
Comment
Question by:mustish1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39772817
You can't, you need a server side language or javascript
0
 

Author Comment

by:mustish1
ID: 39772819
Can I write it down inside the tag without calling any function something like

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

Thanks
0
 
LVL 58

Expert Comment

by:Gary
ID: 39772828
No it would have to be a separate function outside the input.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:mustish1
ID: 39772831
document.javascript.DayOfTheWeek

Something like that
0
 
LVL 58

Expert Comment

by:Gary
ID: 39772833
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

0
 

Author Comment

by:mustish1
ID: 39772847
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>
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39772856
The script needs to be after the input else you will have to wrap it in a function and then put an onload into your body tag. e.g.

<html>
<head>
<title>Test Day</title>
<script>
function setDay(){
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>
<body onload="setDay()">
<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> 

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39772857
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

0
 

Author Comment

by:mustish1
ID: 39773803
Thanks Cathal
0
 
LVL 58

Expert Comment

by:Gary
ID: 39773810
np
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to dynamically set the form action using jQuery.
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.
Suggested Courses

618 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