I have an interesting problem here ...
<cfloop from="1" to="#form.countField#" index="i">
<cfif isdefined('form["semester#i#"]')>
<cfquery name = "insertCourses" datasource="cas_evaluation">
INSERT INTO courses (faculty, semester, course, students, hours, team_taught, first_time, ec_dl, online, course_revision )
VALUES ( '#form.name#', '#form['semester#i#']#', '#form['course#i#']#', '#form['numstudents#i#']#', '#form['hours#i#']#', '#form['team#i#']#', '#form['firsttime#i#']#', '#form['ec_dl#i#']#', '#form['online#i#']#', '#form['revision#i#']#')
</cfquery>
</cfif>
</cfloop>
Basically, I have some dynamic fields that you can add or remove. (These are the lines of the btw fields ...) How did I encode it ... if the user deletes the line in the middle ... (they delete line 2, but lines 1 and 3 remain ...), this causes problems because the loop is looking for it but it clearly does not exist. So I tried to check if one of the fields was defined ... but he doesn’t like the syntax of the variable isdefined .. :(
any suggestions?
source
share