/    Sign up×
Community /Pin to ProfileBookmark

Fairly Easy Date Dropdown problem

[CODE]
/***********************************************
* Drop Down Date select script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var monthtext=[‘Jan’,’Feb’,’Mar’,’Apr’,’May’,’Jun’,’Jul’,’Aug’,’Sept’,’Oct’,’Nov’,’Dec’];

function populatedropdown(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=document.getElementById(dayfield)
var monthfield=document.getElementById(monthfield)
var yearfield=document.getElementById(yearfield)
for (var i=1; i<32; i++)
dayfield.options[i]=new Option(i, i+1)
dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today’s day
for (var m=0; m<12; m++)
monthfield.options[m]=new Option(monthtext[m], monthtext[m])
monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today’s month
var thisyear=today.getFullYear()
for (var y=0; y<10; y++){
yearfield.options[y]=new Option(thisyear, thisyear)
thisyear+=1
}
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today’s year
}
</script>

<script>
//populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
window.onload=function(){
populatedropdown(“daydropdown”, “monthdropdown”, “yeardropdown”)
}
</script>

[/CODE]

Basically this has been used before though i want to modify it so that it dispalys the whole date in a singualr dropdown and ignores sundays as work is not done on sunday

How would i go about this

Thanks in advance

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorApr 26.2011 — It is not very clear which is your aim. What do you need? To write a list box with some dates? Which dates? The next 10 days after today? Or?
Copy linkTweet thisAlerts:
@Macman21authorApr 27.2011 — I will admit i wasn't clear on that

Ideally i would like the next 30 days though i want it to ignore sundays in the dropdown using the current date as the default ie 27/04/2011 in a singular dropdown

Thanks hopefully this clears it up i just read it again and it was not clear


Thnaks for responding hopefully i get this working
Copy linkTweet thisAlerts:
@KorApr 27.2011 — Like this?
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="text/javascript"&gt;
&lt;script type="text/javascript"&gt;
function createBox(){
var date=new Date();
var div=document.getElementById('date');
var sel=document.createElement('select');
sel.name='datebox';
var i,wd,dd,mm,yyyy,option,txt;
for(i=0;i&lt;30;i++){
wd=date.getDay();
dd=date.getDate();
if(wd==0){
date.setDate(dd+1)
i--;
continue
}
mm=date.getMonth()+1;
yyyy=date.getFullYear();
dd&lt;10?dd='0'+dd:null;
mm&lt;10?mm='0'+mm:null;
txt=dd+'/'+mm+'/'+yyyy;
option=document.createElement('option');
option.value=txt;
option.appendChild(document.createTextNode(txt));
sel.appendChild(option);
date.setDate(Number(dd)+1)
}
div.appendChild(sel);
}
onload=createBox
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=""&gt;
&lt;div id="date"&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@Macman21authorApr 27.2011 — Perfectly done you have been most helpful that is exactly what i am looking for
×

Success!

Help @Macman21 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...