i need to get variable from select option in form on live, because it is used in next field in the same form. Any clue how to do it ? I guess it can be done with javascript but i have no idea how to use javascript. Thanks in advance. Here's the code of form :
echo ' <form action="dodaj_harmonogram.php" method="post">';
echo ' <div class="control-group">
<label class="control-label">Nazwa harmonogramu:</label>
<div class="controls">
<input type="text" name="nazwa_harmonogramu" required />
<p class="help-block"></p>
</div>
</div>';
echo 'Profil:<br />
<select name="profil">
'; pobierz_profile();
echo'</select><br>';
echo 'Playlista:<br />
<select name="playlista" id="lista">
'; pobierz_playlisty($id_playlisty);
echo'</select><br>';
$czas_playlisty = zaokraglanieczasu(pobierz_czas_utworow_playlisty($id_playlisty));
$czas_sekundy = ceil($czas_playlisty);
echo ' <div class="control-group">
<label class="control-label">Odstęp (min):</label>
<div class="controls">
<input type="number" min="'.$czas_sekundy.'" name="odstep" required />
<p class="help-block"></p>
</div>
</div>';
echo ' <div class="control-group">
<label class="control-label">Data od</label>
<div class="controls">
<input type="date" name="data_od" required />
<p class="help-block"></p>
</div>
</div>';
echo ' <div class="control-group">
<label class="control-label">Data do</label>
<div class="controls">
<input type="date" name="data_do" required />
<p class="help-block"></p>
</div>
</div>';
echo ' Dni:<br />' ;
?>
<table class="table table-bordered" style="width: 20%;">
<thead><th>Nd</th><th>Pn</th><th>Wt</th><th>Śr</th><th>Cz</th><th>Pt</th><th>Sb</th>
</thead>
<tbody>
<td><input type="checkbox" name="nd" value='1'></td>
<td><input type="checkbox" name="pn" value='1'></td>
<td><input type="checkbox" name="wt" value='1'></td>
<td><input type="checkbox" name="sr" value='1'></td>
<td><input type="checkbox" name="cz" value='1'></td>
<td><input type="checkbox" name="pt" value='1'></td>
<td><input type="checkbox" name="sb" value='1'></td>
</tbody>
</table>
<br>
<br>
Godziny:<br />
<table class="table table-bordered">
<thead><th>0</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th>
<th>12</th><th>13</th><th>14</th><th>15</th><th>16</th><th>17</th><th>18</th><th>19</th><th>20</th><th>21</th><th>22</th><th>23</th>
</thead>
<tbody>
<td><input type="checkbox" name="0" value='1'></td>
<td><input type="checkbox" name="1" value='1'></td>
<td><input type="checkbox" name="2" value='1'></td>
<td><input type="checkbox" name="3" value='1'></td>
<td><input type="checkbox" name="4" value='1'></td>
<td><input type="checkbox" name="5" value='1'></td>
<td><input type="checkbox" name="6" value='1'></td>
<td><input type="checkbox" name="7" value='1'></td>
<td><input type="checkbox" name="8" value='1'></td>
<td><input type="checkbox" name="9" value='1'></td>
<td><input type="checkbox" name="10" value='1'></td>
<td><input type="checkbox" name="11" value='1'></td>
<td><input type="checkbox" name="12" value='1'></td>
<td><input type="checkbox" name="13" value='1'></td>
<td><input type="checkbox" name="14" value='1'></td>
<td><input type="checkbox" name="15" value='1'></td>
<td><input type="checkbox" name="16" value='1'></td>
<td><input type="checkbox" name="17" value='1'></td>
<td><input type="checkbox" name="18" value='1'></td>
<td><input type="checkbox" name="19" value='1'></td>
<td><input type="checkbox" name="20" value='1'></td>
<td><input type="checkbox" name="21" value='1'></td>
<td><input type="checkbox" name="22" value='1'></td>
<td><input type="checkbox" name="23" value='1'></td>
</tbody>
</table>
<br>
<br>
<script>$(function(){
$( "input[type=checkbox]" ).on( "click", function(){
if($(this).is(':checked'))
$(this).parent().css('background-color', 'rgb(36, 255, 0)');
else
$(this).parent().css('background-color', 'rgba(202, 202, 202, 0)');
});
});</script>
<input type="submit" value="Dodaj "button" class="btn btn-info"></button>
</form>
Include jQuery
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
// Then use an event handler to check when the select changes
$('select').on('change', function()
{
// Show an alert
alert( "The new value of the select is " + $(this).val() );
// You should place your logic here to do what you want with that value
// E.g. change the page
document.location.href = $(this).val();
});
</script>