$(document).ready(function () { id = document.getElementByName("ticketid").value; if( id == null) { return false; else $.post('index.php', id); }