Din tutorialul acesta: https://marplo.net/javascript/jquery-ajax-load-js
ce face functia val() din aceasta linie de cod:
Cod: Selectaţi tot
var data = 'pag='+ $('#pag').val();
Multumesc!
Cod: Selectaţi tot
var data = 'pag='+ $('#pag').val();
Cod: Selectaţi tot
$('#pag').val()
Cod: Selectaţi tot
document.querySelector('#pag').value
Cod: Selectaţi tot
<select name="pag" id="pag">
<option value="altu">Altu</option>
<option value="php">PHP</option>
<option value="ajax">Ajax</option>
</select>
Cod: Selectaţi tot
<input type='text' id='pag' value='valoare' name='nume' />
<script>
alert($('#pag').val());
</script>
Cod: Selectaţi tot
$('#crs').submit(function() {
// preia datele din formular
var nm = $('#crs #nm').val();
var cs = $('#crs #cs').val();
var cmt = $('#crs #cmt').val();
// pune date din formular in format JSON, care va fi trimis la server
var data_json = {'nm':nm, 'cs':cs, 'cmt':cmt};
.....
<form action="script.php" method="post" id="crs">
Nume: <input type="text" name="nm" id="nm" /><br />
Curs: <select name="cs" id="cs">
<option value="altu">Altu</option>
<option value="php-mysql">PHP-MySQL</option>
<option value="javascript">JavaScript</option>
<option value="actionscript">ActionScript</option>
<option value="jquery">jQuery</option>
</select><br />
Comentarii:<br />
<textarea name="cmt" id="cmt" cols="20" rows="3"></textarea>
<input type="submit" value="Trimite" />
</form>
Cod: Selectaţi tot
$('#form_id').submit(function(){
//code executed when form #form_id is submited
});