Condition between two arrays for calendar

Asked

Viewed 101 times

0

I have two arrays months and days.

var meses = new Array("Janeiro","Fevereiro","Marco","Abril","Maio","Junho","Julho","Agosto","Septembro","Outubre","Novembro","Dezembro");


 var dias= new Array(31,28,31,30,31,30,31,31,30,31,30,31);

I wanted to make a condition so that for example position 1 (February) would be assigned position 1 of the other array and then print to a table.

1 answer

1

var meses = {
    Janeiro : "31",
    Fevereiro : "28",
    Marco :"31",
    Abril : "30",
    Maio : "31",
    Junho : "31",
    Julho : "30",
    Agosto : "31",
    Septembro : "30",
    Outubre : "31",
    Novembro : "30",
    Dezembro : "30"};

To consult just: console.log(months['January']). Better to associate so as to avoid further processing.

Print out:

<script>
var txt = "";
var meses = {
    Janeiro : "31",
    Fevereiro : "28",
    Marco :"31",
    Abril : "30",
    Maio : "31",
    Junho : "31",
    Julho : "30",
    Agosto : "31",
    Septembro : "30",
    Outubre : "31",
    Novembro : "30",
    Dezembro : "30"};
var x;
for (x in meses) {
    txt += meses[x] + " ";
}
document.getElementById("demo").innerHTML = txt;
</script>

</body>
</html>
  • right, and now print a table for home month?

  • console.log(months['January'])

  • yes, but this shows me only 31. I wanted to show every day, with the respective weekdays.

  • You want to print type January: every day until the end of the month and so on?

  • yes exactly that, print January, with its 31 days, and dps the other months. And show Monday, Tuesday, ...

  • you want to do it in what language?

  • javascript language

  • access this link: http://codigofonte.l.com.br/codigos/combo-calendario-em-javascript

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.