Eduardo Posted July 6, 2016 Report Share Posted July 6, 2016 I have a list whose value when there is no item selected is 1. If any item is selected, I want to write "Education" to the field "Program Area". I have been able to display an alert with the message "Education", but it doesn't commit to the table. This is the code that I have: function writeProgramArea() { var fieldName1 = "InsertRecordPoFED"; var x1=document.getElementsByName(fieldName1); if (x1[0].value != "1") { var xProgramArea = document.getElementsByName("InsertRecordProgramArea"); xProgramArea.value="Education"; alert(xProgramArea.value); } } document.getElementById("caspioform").onsubmit=writeProgramArea; What am I missing? Thanks! Eduardo Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 6, 2016 Report Share Posted July 6, 2016 The syntax of the element when is being called with name should be: var xProgramArea = document.getElementsByName("InsertRecordProgramArea")[0]; Change this line and see if that works. Quote Link to comment Share on other sites More sharing options...
Eduardo Posted July 7, 2016 Author Report Share Posted July 7, 2016 Awesome! you solved the problem, as always 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.
Note: Your post will require moderator approval before it will be visible.