Simple JS function

Discussion in 'JavaScript' started by Mackos, May 20, 2011.

  1. #1
    Hello!
    I want to write a simple function for my visitors. They have to choose hours.
    and I have something like that:
    <script type="text/javascript">
    function Godzina() {
      var godzina = document.getElementById('godzina');
      var wartgodz = document.getElementById('wartgodz');
      switch (godzina.value) {
        case '0' : wartgodz.innerHTML = 'From hour: <select name="godzina"><option value=\"$go:00\">$go:00</option><option value=\"$go:30\">$go:30</option></select><br>To: <select name="godzina2"></option>"; ><option value=\"$go:00\">$go:00</option><option value=\"$go:30\">$go:30</option></select>'; break; // I deleted my PHP code from here
        case 'wyb' : wartgodz.innerHTML = ''; break;
        default  : wartgodz.innerHTML = 'wartgodz.innerHTML = 'From hour: <select name="godzina"><option value=\"$go:00\">$go:00</option><option value=\"$go:30\">$go:30</option></select><br>To: <select name="godzina2"></option>"; ><option value=\"$go:00\">$go:00</option><option value=\"$go:30\">$go:30</option></select>'; break;'; break; // I deleted my PHP code from here
      }
    }
    </script>
    HTML:
    But I want to "godzina2" tag to be +3 hour's bigger than "godzina" chosen by user
    How to do that?
     
    Mackos, May 20, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    Do you mean like changing the $go variables, with ($go+3) variables in the godzina2 options?
     
    ssmm987, May 20, 2011 IP