I want add value in jquery function an post it to my php file. I call my jquery function whit onclick event but i don't know how can add value. I have this input tag:
<input type="hidden" name="code" id="code" value="<?php echo $code; ?>" />
and my onlick event this is:
<span onClick="previewed_files(); checkDb();">start</span>
and my checkDb function it is:
<script type="text/javascript" >
function checkDb(adscode){
$.post('myphp.php',{adscode: adscode},function(data){
$('#mydiv').html(data);}
);
}
</script>
now I can't call value from input by id code in my checkDb() function in onclick event. please help me. thank you
Here :
<script type="text/javascript" >
function checkDb(adscode){
$.post('myphp.php',{adscode: adscode, value: $('#code').val()},function(data){
$('#mydiv').html(data);});
}
</script>
You must check for ajax tutorials
to get value in php. You cant get parameter value in function untill you pass in the function.
to get value of hidden variable -
var value = jQuery('#code').val();
Now, you can use this variable in your funciton.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.