VVMustang Posted August 15, 2011 Report Share Posted August 15, 2011 I'm trying to insert values in fields in an Submission Page based on the values of adjacent fields. The script is in the Footer. It is not working. The Organizer_Fee, Yearbook_Fee and BookClub_Fee are being populated with the "Yes" value every time. Here's my script: function calculate() { var order_organizer = (document.getElementById("InsertRecordOrganizer")); var order_yearbook = (document.getElementById("InsertRecordYearbook")); var order_bookclub = (document.getElementById("InsertRecordBookClub")); if (order_organizer = "Yes") { document.getElementById("InsertRecordOrganizer_Fee").value = (10); } else { document.getElementById("InsertRecordOrganizer_Fee").value = (0); } if (order_yearbook = "Yes") { document.getElementById("InsertRecordYearbook_Fee").value = (25); } else { document.getElementById("InsertRecordYearbook_Fee").value = (0); } if (order_bookclub = "Yes") { document.getElementById("InsertRecordBookClub_Fee").value = (50); } else { document.getElementById("InsertRecordBookClub_Fee").value = (0); } } /* On submitting the webform, the function calculate is executed */ document.getElementById("caspioform").onsubmit=calculate; Quote Link to comment Share on other sites More sharing options...
Aariel Posted August 15, 2011 Report Share Posted August 15, 2011 hello, I see that you have only one '=' for 'if' statement. The comparison should always be '=='. Also, I don't know if document.getElementById("InsertRecordBookClub_Fee").value = (0); is how we assign value to a field. I have always used like: document.getElementById("InsertRecordBookClub_Fee").value = 0; i.e without brackets in the value. Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted August 15, 2011 Report Share Posted August 15, 2011 When trying to access a form element, the type of the form element is important. For example if the form element is a radio, the way you reference it in the script is different. Example: If Organizer is a radio button, note that a radio button element normally does not have an ID for itself however each option of the radio button has it’s own ID which can be referenced as: InsertRecordNameX X can be 0 for the first option, 1 second option and so far… So you may need to make some changes to your script. Best, Bahar M. 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.