Skip to main content
Known Participant
April 9, 2010
Question

How to update and insert from same page using type="submit" or "button"

  • April 9, 2010
  • 1 reply
  • 868 views

I am trying to remember where I saw the technique of adding a separate button to a coldfusion or flex page, other than the submit button, and calling a function to do something different like a query into database on insert page without inserting if onclick for update button is event.

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 18, 2010

    Hi Gregory,

    If I understand what it is you are trying to accomplish, perhaps something

    like this:

    <cfinput type="button" name="update_record">

    below would send you to designated page and pass the record_id var to

    the page, along with any additional forms

    onClick="this.form.action='http://path/to/cf_page.cfm?record_id=#URLEncodedFormat(record_id)#';this.form.submit()" onMouseOver="style.cursor='pointer'"

    - or -

    <cfinput type="submit" name="btn_insert" ..>

    <cfinput type="submit" name="btn_update" ...>

    then on same page try the following:

    <cfisdefined('form.btn_insert')>

    - - - do whatever it is you want done

    <cfisdefined('form.btn_update')>

    - - - do whatever it is you want done

    Leonard B

    Known Participant
    April 20, 2010

    When I get back to that page, your second example seems like it might work out. I might also try

    using Phillip Churvis's advanced custom tag technique from Advanced Macromedia ColdFusion MX7 Application Development, in which one page adds, deletes, updates, and views records from a database.