I declared two variables globally, first one is input text field and second is select field. When I change the option field, the local variable values set is to the global variables. But global variables didn’t got the values.
<script type="text/javascript">
var id1;
var opt1;
$(document).ready(function() {
$("#opt").change(function() {
id = $("#id").val();
opt = $("#opt").val();
id1 = id;
opt1 = opt;
if(!id=="" && !opt=="") {
//alert(id);
} else { }
});
</script>
The problem is down to the “minimised” formatting you’ve tried to use; it makes your code impossible to read, and therefore you’ve missed the fact that you’re missing a closing bracket. Reformatting the code will help you spot this. In addition you also used a
//comment, in the middle of it which results in the rest of the line being commented out, meaning that your brackets are even more out of sync.The answer is to write your code in a properly indented format, rather than trying to put it all onto one line. If you want it minimised, don’t do it yourself; there are tools that can do that for you, and only do it for the copy you put online, not the copy you’re testing with; the version you work with and test with should be properly formatted.