Darghon Posted April 29, 2009 Share Posted April 29, 2009 I have a form with several tabs, the tabs are all identical but represent data from different environments. so the text fields have names like date_approved[16] representing the date_approved for environment 16. Now I want to generate input checks for all tabs, so I generate checks like the following, but they don't work, any solutions? //frm is a passed variable that contains the document.form if(frm.prod_apprby[16].value != "" && frm.prod_dtappr[16].value == ""){ alert("Env 16: Production Approved by can not be filled in if date approved is blank."); return false; } Thx in advance Quote Link to comment Share on other sites More sharing options...
radi8 Posted April 29, 2009 Share Posted April 29, 2009 This post is awesome in javascript debugging: http://www.phpfreaks.com/forums/index.php/topic,249936.0.html I would HIGHLY suggest using FireFox and FireBug! This combination will help you immensely in troubleshooting and developing your javascript. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 29, 2009 Share Posted April 29, 2009 document.form is wrong. It should be document.forms. I assume prod_apprby is the form name? If so, frm.prod_apprby[16] doesn't make sense to me. Can you show me the HTML for the form? Quote Link to comment Share on other sites More sharing options...
Darghon Posted May 4, 2009 Author Share Posted May 4, 2009 document.form was not what frm stood for, to be more detailed, frm was => document.frmRequest so frm.prod_apprby[16] was => document.frmRequest.prod_apprby[16] where "prod_apprby[16]" was the name of a field in the form I managed to solve this with the following statement: document.getElementsByName("prod_apprby[16]")[0].value This would give me the value of that field, and not an undefined error like the previous attempt did. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 I don't know why you have brackets like that, but you could have done: document.forms["formname"]["prod_apprby[16]"].value 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.