• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

button and struct[empty]

Explorer ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

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

Views

826

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

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

-Carl V.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

<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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

PS

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

If you want the buttons inside the form, have you tried changing them to inputs instead: <input id="editbutton" type="button" value="Edit">, or at least adding the type="button" attribute to the existing <button> tags?

Depending on the browser, the <button> element may default to type="submit" (which submits the form) rather than type="button" (which doesn't do anything unless you intercept the click event in JavaScript).

-Carl V.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

LATEST

Interesting... Thanks for your input (that was a sweet pun eh?). I am a student and new to development, recently started working at my university doing web dev. Thank you for you quick reply. I am going to try this at work on monday and I will get back to you.

Thanks!

-gwarmonger

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation