Hello, fellow jQ people! I have three questions about jQuery.
1) I have a web form in a jQuery popup. For that web form to function, I need to pass a value to it. Following code demonstrates how I am processing the form using jQuery: Code: $(document).ready(function(){ $(".addbutton").click(function(){ //add button in HTML centerPopup(); // works fine loadPopup(); //works fine }); $("form#edituser").submit(function() { usrObj.act = $('#modaction').val(); if (usrObj.act == 'add_user') { usrObj.usr = $('#newusername').val(); var dataString = 'newusername='+ usrObj.usr; $.ajax({ type: "POST", url: "showusers.php", data: dataString, complete: function(){ $('form#edituser').hide(); $('div.success_form').show(); $('div.success_form').fadeOut("slow",refreshPage(10)); //$('div.success_form').fadeOut("slow",$ ('#footer').animate({scrollTop:0}, 'slow').refreshPage(10)); } }); return false; }); }); Following code is for the popup div: Code: printf ('<div class="ajaxpopup">'); someFunc($var); printf ('</div>'); So, there are several buttons with a different parameter each. When clicked, they open the same div.ajaxpopup. I somehow need to pass a parameter to someFunc(), whcih is in <div class="ajaxpopup"> For someFunc() to work it needs to read $var. Prior to AJAX, I had popup content on a separate page. So, I would use a web form with POST action instead of .addbutton. So, my question is how do I pass a var from parent page to child popup so it can then be passed to a php function? 2) For the form described, users might need to add a new user name. So, if the user name already exists in db I want to send an error message back to the popup saying "user can't be added as it already exists" I am pretty sure it can be possible with jQuery. I tried searching online but I could not find any helpful example. Can you please demonstrate it. 3) I am using the following conditional statements to validate inputs: Code: if (usrObj.usr == "" && usrObj.pwd == "" && usrObj.pwdc == "" && usrObj.company == "") { $("label#company_blank").show(); $("label#usr_name_blank").show(); $("label#pwd_blank").show(); $("label#pwdc_blank").show(); $("#newusername").focus(); return false; } if (usrObj.usr == "" && usrObj.pwd == "" && usrObj.pwdc == "") { $("label#usr_name_blank").show(); $("label#pwd_blank").show(); $("label#pwdc_blank").show(); $("#newusername").focus(); return false; } if (usrObj.pwd == "" && usrObj.pwdc == "") { $("label#usr_name_blank").hide(); $("label#pwd_blank").show(); $("label#pwdc_blank").show(); $("#newpassword").focus(); return false; } if (usrObj.usr == "" && usrObj.pwdc == "") { $("label#pwd_blank").hide(); $("label#usr_name_blank").show(); $("label#pwdc_blank").show(); $("#newusername").focus(); return false; } if (usrObj.usr == "" && usrObj.pwd == "") { $("label#pwdc_blank").hide(); $("label#usr_name_blank").show(); $("label#pwd_blank").show(); $("#newusername").focus(); return false; } if (usrObj.company == "") { $("label#company_blank").show(); $("label#usr_name_blank").hide(); $("label#pwd_blank").hide(); $("label#pwdc_blank").hide(); $("#newusername").focus(); return false; } if (usrObj.usr == "") { $("label#usr_name_blank").show(); $("label#pwd_blank").hide(); $("label#pwdc_blank").hide(); $("label#company_blank").hide(); $("#newusername").focus(); return false; } if (usrObj.pwd == "") { $("label#pwd_blank").show(); $("label#usr_name_blank").hide(); $("label#pwdc_blank").hide(); $("label#company_blank").hide(); $("#newpassword").focus(); return false; } if (usrObj.pwdc == "") { $("label#pwdc_blank").show(); $("label#pwd_blank").hide(); $("label#usr_name_blank").hide(); $("label#company_blank").hide(); $("#newpasswordconfirm").focus(); return false; } It turns out an increasing number of input text fields quadruples (roughly speaking) the number of conditional statements required for validation. So, is there a better way to validate form inputs. Thank you very much for your kind help!