To choose a date and get the week and enable select with specific values

Asked

Viewed 238 times

1

I wonder if they can help me because I’ve been "cracking my brain" for days:

  1. Clicking a text input opens a calendar and then I choose a date;
  2. I need another input text to calculate the day of the week (Tuesday or Thursday only) based on the chosen date
  3. And through the input text of the day of the week, should be visibled the select to choose the time: TUESDAY = 14:30, 14:50, 15:10, 15:30 and 15:40 and THURSDAY = 09:40, 10:10, 10:30, 10:50 and 11:10

I’m trying to get the date with the document.getElementById, but precisely in this field nothing happens! It will be because of the calendar...

function escrever(el) {
    var isso = document.getElementById('calendSemana').value = el.value; 

    //var dias_semana = new Array("Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado");
    //var data = new Date();
    //var dia = data.getDay();

    //document.write(dias_semana[dia]);

    //linhasOcultas = (dias_semana[dia]);

    //document.getElementById("#calendSemana").value(linhasOcultas);

    //var campoValor = document.getElementById("celular").value;
    //document.write(linhasOcultas);
    //document.getElementById('calendSemana').value += campoValor;

    //document.write("<input type='text' class='inputcad' id='calendSemana' name='calendSemana' maxlength='10' value='"+isso+"'>");

    //document.getElementById('#calendSemana').value = document.getElementById('#data_3').value;

    //document.getElementById('calendSemana').innerHTML = el.value;

}

<script type="text/javascript">
     function mostraDiv(valor) {
          if(valor == "Terça")
          {
                document.getElementById("TER").style.display = "block";
                document.getElementById("QUI").style.display = "none";
          }
          else if(valor == "Quinta")
          {
                document.getElementById("TER").style.display = "none";
                document.getElementById("QUI").style.display = "block";
          }
          else if(valor == "Selecione")
          {
                document.getElementById("TER").style.display = "none";
                document.getElementById("QUI").style.display = "none";
          }
}
</script>

<select name='dia' id='dia' class='inputselec' onchange='mostraDiv(this.value)'>
<option value="<? echo $_SESSION['dia_c']; ?>"><? if(empty($_SESSION['dia_c'])) { echo "Selecione"; } else { echo $_SESSION['dia_c']; } ?></option>
<option value='Terça'>Terça-feira</option>      
<option value='Quinta'>Quinta-feira</option>
</select>

<div id='TER' style='display:none'>
<select name='terca' id='terca' class='inputselec'>
<option value="<? echo $_SESSION['terca_c']; ?>"><? if(empty($_SESSION['terca_c'])) { echo "Horário"; } else { echo $_SESSION['terca_c']; } ?></option>
<option value='14:30'>14:30</option>
<option value='14:50'>14:50</option>
<option value='15:10'>15:10</option>
<option value='15:30'>15:30</option>
<option value='15:40'>15:40</option>
</select>
</div>
<div id='QUI' style='display:<? echo $mostraQ ?>'>
<select name='quinta' class='inputselec'>
<option value="<? echo $_SESSION['quinta_c']; ?>"><? if(empty($_SESSION['quinta_c'])) { echo "Horário"; } else { echo $_SESSION['quinta_c']; } ?></option>
<option value='09:40'>09:40</option>
<option value='10:10'>10:10</option>
<option value='10:30'>10:30</option>
<option value='10:50'>10:50</option>
<option value='11:10'>11:10</option>
</select>
</div>

I thank very much to those who can help me... Light and Peace!

  • 1

    Java? Wouldn’t it be Javascript?

  • Welcome to Stackoverflow English, please read the [Ask]. Try to include in your question the code you have.

  • Yes... Javascript... and I only have tentavivas...

  • Hi Paulo, welcome to Stack Overflow. In order for you to get the proper help, and for the rest of the community to benefit from the posted content, it is important that you create a MVCE. We need to know exactly what this calendar is to give you a specific answer. Take a look at How to ask a good question. One of the good ways to do this for Javascript is to click the button Trecho JavaScript/HTML/CSS and stick your example.

  • How can I enter the calendar codes? Thank you!

  • Hi Paul, clicking edit you will see some buttons on top of the text box. The sixth button (with a symbol of <>) allows you to paste your code snippets and generate an executable calendar example.

Show 1 more comment
No answers

Browser other questions tagged

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