mcmuney Posted March 4, 2009 Share Posted March 4, 2009 I have a form that utilizes javascript to pass the form data, to which, I'm trying to add a checkbox. But regardless if the box is checked or not, the same value "Y" is being passed. What do I need to do so it differentiates if the box is checked or not??? Javascript Portion function sub(frm) { if(frm.txt_comment.value=="") { alert("Did you forget to enter your comment?"); return false; } else { var comment_text=frm.txt_comment.value.escapeHTML(); comment_text = comment_text.replace(/\//g,"%2F"); comment_text = comment_text.replace(/\?/g,"%3F"); comment_text = comment_text.replace(/=/g,"%3D"); comment_text = comment_text.replace(/&/g,"%26"); comment_text = comment_text.replace(/@/g,"%40"); frm.hinsert.value='True'; frm.sci_id.value=<?=$sci_id?>; //frm.submit(); var pars = "txt_comment="+comment_text+"&txt_anon="+frm.txt_anon.value+"&sci_id="+frm.sci_id.value+"&hinsert="+frm.hinsert.value+'&update='+frm.update.value+ '&scm_mem_id=<?=$scm_mem_id?>'; new Ajax.Updater({success:'silentPost'},'code/Ajax_comment_posting/postPictureComment.php', {method: 'post', parameters: pars, onLoading:onStartPosting, evalScripts:true, onFailure:onPostingFailed}); } } This is the checkbox that I'm trying to add <input type="checkbox" name="txt_anon" value="Y"> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 4, 2009 Share Posted March 4, 2009 the value will always be the same. you need to check to see if "checked" is true. var pars = "txt_comment="+comment_text; if(frm.txt_anon.checked) pars += '&txt_anon='+frm.txt_anon.value; pars += '&sci_id='+frm.sci_id.value+'&hinsert='+frm.hinsert.value+'&update='+frm.update.value+'&scm_mem_id=<?=$scm_mem_id?>'; Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted March 6, 2009 Share Posted March 6, 2009 can u upload this ajax thing ...then i will updated it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.