Skip to main content
Inspiring
December 20, 2013
Question

button and struct[empty]

  • December 20, 2013
  • 1 reply
  • 986 views

I have a form with Javascript, two buttons "EDIT" and "SORT". There is Jquery-UI code for click and dragging list items that are pulled into the form from a database. When you click button "EDIT", it adds the HTML5 attribute "contenteditable" and adds a class "unsortable" which disable the sort function and allows you to edit in place. When you click "Sort" it removes the "contenteditable" attribute and "unsortable" class and lets you sort again.

Problem - If the buttons are outside of the form then it works fine. If the buttons are inside of the form I get an error struct[empty].  Why?  I don't need buttons that pass values, I just need them to trigger the javascript.   Also, it is not a cfform, just a regular html form.

There is a 3rd button, SAVE that when clicked will save the edited changes and order to the database. ...I haven't got that far yet.

This is the only way I can figure to do an edit in place on this page... any ideas/help would be great!

Thanks,

gwarmonger

This topic has been closed for replies.

1 reply

Carl Von Stetten
Legend
December 20, 2013

Can you post the portion of the HTML code that contains the form and buttons?  It would help very much.

-Carl V.

Inspiring
December 20, 2013

<cfif isdefined('url.id')>

    <cfset id = #url.id#>

    <cfquery datasource="db_cie" name = "qGetFacultyCV">

    select a.fname, a.lname, b.full_citation, b.pub_date, b.id, b.faculty_id

    from nrc_faculty a, publications b

    where a.faculty_id = #id#

    and a.faculty_id = b.faculty_id

    order by sort_order, a.lname

        </cfquery>

<!---    <cfoutput> #qGetFacultyCV.faculty_id#</cfoutput>

<!------>    <cfif '#qGetFacultyCV.full_citation#' NEQ ''>

--->   

    <cfset thisString="#qGetFacultyCV.id#">

    <h1>

    Edit CV For: <cfoutput>#qGetFacultyCV.lname#, #qGetFacultyCV.fname#

        </h1>

      </cfoutput>

    <h3>Select publication to edit:</h3>

    <cfoutput>

        <!---  <input name="faculty" type="hidden" value="#id#" />--->

      </cfoutput>

   

    <form action="update-sort.cfm?faculty_id=<cfoutput>#qGetFacultyCV.faculty_id#</cfoutput>" method="post" id="frm-sort">

       

    <ul id="sortable">

        <cfloop query="qGetFacultyCV">

        <cfoutput>

            <li "id="section_id_#qGetFacultyCV.id#" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>#qGetFacultyCV.full_citation#</li>

          </cfoutput>

      </cfloop>

      </ul>

  

    <input type="submit" name="delete" value="Delete Publication" />

    <input type="submit" name="save" id="save" action="addaction.cfm" value="Save" />

   

  <!--- <input type="hidden" name="sort_serialized" class="sort_serialized" value="" />--->

   <!---><input type="hidden" name="faculty_id" id="faculty_id" value="<cfoutput>#qGetFacultyCV.faculty_id#</cfoutput>" />--->

    <!---<cfelse>

    <h1>This faculty member has no publications on record.</h1>

    <input type="submit" name="add_pub" value="Add Publication" />

  </cfif>--->

  </cfif>

</form>

    <button id="editbutton">Edit</button>

    <button id="sortbutton">Sort</button>

     <button id="addbutton">Add Publication</button>

    <h3 id="drag" style="display:none">Click and drag to sort.</h3>

    <h3 id="edit" style="display:none">Click and type to edit.</h3>

And then there is code to insert into database

<cfinsert datasource="db_cie" tablename="#qGetFacultyCV#">

I tried that code without the hash signs and just putting in the table name. None worked. When I click the button all I get is a "Struct Fieldnames: SAVE

Save: Save

Thanks!

Inspiring
December 20, 2013

PS

I didn't write the code. Modifying someone else's code.  :/    Not one of my favorite tasks.