Insert multiple records in a form with checkboxes

Hello

I need to insert multiple records in a database of a form using Coldfusion and am stuck - it works correctly when inserting one record at a time. Basically, the user will choose their name of the employee (EmployeeID) in a dynamic list, then several session (open) numbers that represent classes of training.

When I try and select several check boxes, I get this error:
"The number of query values and destination fields is not the same."

The boxes of the open field are not dynamic, as you can see-how use CFLOOP or any other method to allow several checkboxes be selected, and all open documents is entered into the database on a form?

I used server behaviors Dreamweaver 8 to create the form - which is limiting I know but I'm not a coder. I hope I can add code here to do things correctly function.



----APPLICATION CODE------------------------------------------------------------------

<!-get employee names->
< cfquery name = "rsDisplayEmployee" datasource = "FormationRH" >
SELECT *.
OF tblEmployees
ORDER BY LastName ASC < / cfquery >
<!-->-->
<! - insert Records - >
< cfset CurrentPage = GetFileFromPath (GetTemplatePath ()) >
< cfif IsDefined "(FORM. MM_InsertRecord") AND the FORM. MM_InsertRecord EQ 'form1' >
< cfquery datasource = "FormationRH" >
INSERT INTO tblEnrollments (open, EmployeeID)
VALUES)
< cfif IsDefined "(FORM. Open") AND #FORM. Open # NEQ "" > "".
#FORM. Open #.
< cfelse >
NULL VALUE
< / cfif >
,
< cfif IsDefined "(FORM. EmployeeID") AND #FORM. EmployeeID # NEQ "" > "".
#FORM. EmployeeID #.
< cfelse >
NULL VALUE
< / cfif >
) < / cfquery >
< cflocation url = "2.cfm" >
< / cfif >
<!-->-->

--------FORM CODE-----------------------------------------------------------------------

< form action = "" < cfoutput > #CurrentPage # < / cfoutput > "id = 'form' name ="form"method ="POST">"
< table width = "100%" border = "0" cellspacing = "0" cellpadding = "4" >
< b >
< td width = "100%" > < h2 > < strong > select an employee name < facilities > < / h2 > < table >
< /tr >
< b >
< td > < select name = "EmployeeID" >
< cfoutput query = "rsDisplayEmployee" >
< option value = "#rsDisplayEmployee.EmployeeID #" > #rsDisplayEmployee.LastName #, #rsDisplayEmployee.FirstName # < / option >
< / cfoutput >
< / select > < table >
< /tr >
< /table >
< h2 > < strong > select training class < facilities > < / h2 >
< table width = "600" border = "0" cellspacing = "0" cellpadding = "0" >
< b >
< td width = "227" valign = "top" > class < table >
< td width = "373" valign = "top" > < input name = "Open" type = "checkbox" value = "937" / >
Date < table >
< /tr >
< b >
< td valign = "top" > class < table >
< td valign = "top" > < label >
< input name = "Open" type = "checkbox" value = "936" / >
< / label >
Date < table >
< /tr >
< /table >
< br / >
< input type = "submit" name = "Submit" value = 'Sign Up!' / >
< input type = "hidden" name = "MM_InsertRecord" value = "form" >
< / make >

"Add a line" I want to say that, for each of the checkboxes selected in your form, the code will be to insert a new record in the database table. Sorry I probably didn't phrase it very well.

so, no, the code does not need to wrap around each element. Instead the code examines the form.fieldnames variable (form.fieldnames, which is a list separated by commas of all fields defined in the form, is automatically submitted to each form submission - you don't have to define yourself somehow) and for each selected checkbox will insert a new record in your table with the check box selected and selected value the value of the id of the employee.

Tags: ColdFusion

Similar Questions

  • delete a multiple record in slot table with checkbox form.

    Hello guys,.

    I need your suggestions...


    I have the block master detail. (SECTION and INSTRUCTOR)

    The retail block, I add checkbox element (name: RB_SECTION_ID) with part of database 'No' and when to check the value: SECTION_ID (on property).

    I do a DELETE button. The trigger was the DELETION of the ARTICLE where section_id =: SECTION. RB_SECTION_ID and
    instructor_id =: are you doing. INSTRUCTOR_ID;

    but it does not work.

    How delete us record multiple check multiple check box, and then click DELETE... ??


    View.

    NIA...

    Because your delete statement reflected until it is saved or re-queryied...

    Add Lee after the END of the LOOP;
    execute_query (no_validate);

  • Insert multiple record Oracle forms 6i/9i / 10g

    Hello

    How can I insert multiple record using a tabular view as an oracle.

    what I use for loop?

    can someone help me? I have kindda stuck in this problem...


    Scenario:
    I have 5 display of last_name text_item and I put 4 names on it...

    If I use Insert, it only get the 4th name I drove...

    question:
    How can I put them all together?

    I build the block manually.

    Not a very good idea, I think, but if you really want to do it this way, you will need to loop through the records:

    first_record;
    <>
    loop
       insert into ....
       exit when :system.last_record = 'TRUE';
       next_record;
    end loop record_loop;
    
  • Insert multiple records in a query from a loop

    Hello

    Im am seriously struggling with something here...


    PROBLEM:
    I want to insert multiple records of checkbox in my db...
    A simple insert statement inserts the 1 record...

    How can I insert all records?

    For example: 10 family names must be inserted at the same time...

    Check my code...


    PLEEEASE, im really craving for help!

    Thank you. Worked perfectly!

  • Insert multiple records in a database using the DB adapter and stored procedure

    Hi all

    I want to insert multiple records in a database using a stored procedure. I wanted to insert these records using a data adapter and data adapter must be called by a mediator.

    Can anyone suggest me some ideas if it's possible with capabtilities OOB in SOA suite or not?

    Thank you for your help in advance.

    Thank you
    Shiv

    The trick is in the stored procedure. You must use a data type that will handle multiple records I use varray. An example can be found in this post.

    Re: Mutiple calls to AppsAdapter (pl/sql) when the payload has multiple records

    When you read the procedure stored in the db adapter wizard looks and xsd / xml if you have maps accordingly.

    see you soon
    James

  • I created a form with checkboxes.  A question has two boxes for a 'yes' another being a 'no '.  I just want to be able to select a single box, but currently, I choose both

    I created a form with checkboxes, I have currently two checkboxes in a question that I wish I could only check a box and make it mandatory that should be checked only one box.  Currently, I am able to select the two check boxes.

    Give them the same field name, but export values.

  • Insert multiple records in the single form

    Hi all

    I met already insert many rows into a table using ADF BC. The solution is in the following thread

    Re: How to create several new lines in the Table of the ADF?

    However,.
    The above solution is useful when you want to enter new values as well as all the table entries is displayed.
    What can I do if I don't want all values in the table, but just a page 'AddEntries' where I can only add new lines without going through the table entries is displayed.

    As,

    Say a form has 5 rows

    Each line has empId, eMailSlNo, send attributes

    EmpId is the same for all 5 recordings but emailId is different.

    EmpId eMailSlNo plus the PK.

    empId generated by the sequence.

    Now, on presentation of the form, I want all five records to be inserted.

    (can I use ADF form instead of the table of the ADF for the ViewObject in this case. I tried ADF form but I could only insert 1 plug at the same time).

    I use 10.1.3.4

    Help, please.

    Thanks in advance,
    Shri

    Published by: newtoOTN on December 29, 2009 18:02

    Shri salvation,

    ADF form is intended for the single insert/update. For multiple insert/update/delete using the collection as table UI is preferred. I guess your db table or table design INTERFACE default (in my opinion but I do not know your usecase entirely, so I guess might b wrong).

    I would say,

    -make EmpId as PK
    -have another table to store EmpId (foreign key), emailSiNo, email
    -Having the relationship of the master / detail between the British Colombia ADF db tables.
    -Create master / detail UI and on the selection of the master, view the details and if no record is found does not add files and commit.

    See these examples:
    http://www.Oracle.com/technology/products/jdev/tips/Mills/MasterDetailSync/Master_Detail_Synchronization_in_ADF_Faces.html
    http://andrejusb.blogspot.com/2007/06/create-edit-and-delete-operations-in.html

    Hope it makes sense.

    ~ K

  • Calendar - insert multiple records by account number/length of

    Hello

    I would write a process allowing to insert multiple rows in a table. I think it should be a LOOP statement, but I don't know how in the APEX.

    I got a simple form with the following page:

    P2_Calendar_ID-> hidden field, populated by standard processes to Get PK to generate IDS again for the insert statement

    P2_Name-> text field

    P2_Date-> Date picker field

    P2_Duration-> numeric field

    The user name (P2_Name), choose a date (P2_Date) and type in a number (P2_Duration) and send the form. Here, I need the above mentioned process of pl/sql.

    I think that first of all it must be created a loop to generate the Dates of the picked a (P2_Date) and increment the date by the number (P2_Duration), and store dates in the variable. Then there should be another loop to insert the number of records in a table, so it has inserted the same number of rows depending on the number in P2_Duration and with the dates increment according to the P2_Duration.

    Name of the CALENDAR table after columns:

    Calendar_ID-> number)

    Name-> varchar2

    Date-> Date

    Example of what the user will fill in the form above:

    P2_Name-> Vladimir

    P2_Date-> may 9, 2014

    P2_Duration-> 3

    It must be created the following lines in a table CALENDAR:

    Date name Calendar_ID

    1 Vladimir may 9, 2014

    2 Vladimir 10 may 2014

    3 Vladimir may 11, 2014

    Of course the Calendar_ID is generated by the standard Get PK process, which might need to be included in the loop... I think so.

    Thank you for your help.

    Best regards

    Vladimir

    PS: I use the APEX Version: Application Express 4.2.5.00.08

    Hi Vladimir,.

    Simply create a process on submit more info here: 8.5 Page understanding the process , with your touch as a trigger and add the code in this document, similar to the below I would say: and you can just get rid of the hidden element calendar_id

    Thank you

    DECLARE

    DATE OF T_DATE;

    BEGIN

    FOR DATEINC IN 0.TO_NUMBER(:P2_DURATION) - 1 LOOP

    T_DATE: = TO_DATE(:P2_DATE,'DD-MON-YYYY') + DATEINC;

    INSERT INTO CALENDAR (CALENDAR_ID, NAME, DATE) VALUES (CAL_ID_SEQ.nextval,: P2_NAME, T_DATE);

    END loop;

    END;

  • inserting multiple rows of another table with incremented recordid

    Hi all

    I HAVE TWO TABLES:

    CREATE TABLE TEMP_TEST1)
    NUMBER OF RECID,
    TESTCHAR VARCHAR2 (500)
    )

    AND

    CREATE TABLE TEMP_TEST2)
    TESTCHAR VARCHAR2 (500)
    )

    Both the table contains data in it. I want to insert data from TEMP_TEST2 in TEMP_TEST1 with RECID incremented for each record, which must be greater than max (RECID) of TEMP_TEST1.
    PS: I have to query insert only, I cannot make changes in the structure of table or RECID of TEMP_TEST1 is not automatically incremented.
    Please suggest a query that selects the record of TEMP_TEST2 and TEMP_TEST1 insert with recid incremented for each record.


    Thank you.
    SQL> insert into TEMP_TEST2(TESTCHAR)
      2  select 'Test'||level from dual connect by level < 10
      3  /
    
    9 rows created.
    
    SQL>
    SQL>
    SQL> insert into TEMP_TEST1(RECID,TESTCHAR)
      2  select (select nvl(max(RECID),0) from TEMP_TEST1) + rownum, t2.TESTCHAR
      3  from TEMP_TEST2 t2
      4  /
    
    9 rows created.
    
    SQL>
    SQL> select * from TEMP_TEST1
      2  /
    
         RECID TESTCHAR
    ---------- ----------
             1 Test1
             2 Test2
             3 Test3
             4 Test4
             5 Test5
             6 Test6
             7 Test7
             8 Test8
             9 Test9
    
    9 rows selected.
    
    SQL> insert into TEMP_TEST1(RECID,TESTCHAR)
      2  select (select nvl(max(RECID),0) from TEMP_TEST1) + rownum, t2.TESTCHAR
      3  from TEMP_TEST2 t2
      4  /
    
    9 rows created.
    
    SQL>
    SQL> select * from TEMP_TEST1
      2  /
    
         RECID TESTCHAR
    ---------- ----------
             1 Test1
             2 Test2
             3 Test3
             4 Test4
             5 Test5
             6 Test6
             7 Test7
             8 Test8
             9 Test9
            10 Test1
            11 Test2
    
         RECID TESTCHAR
    ---------- ----------
            12 Test3
            13 Test4
            14 Test5
            15 Test6
            16 Test7
            17 Test8
            18 Test9
    
    18 rows selected.
    
    SQL>
    

    Good bye
    DPT

  • Insert multiple record Oracle forms 6i

    Hi all

    I have a single column of field Field1, button, in the form TEXT_ITEM1.

    After giving the sales order number in Field1, when should press us the button, the items (item_code) shown in the TEXT_ITEM1.

    I went through the discussion Insert several Oracle forms 6i, 9i/10 g recordbut did not exactly how to write the loop button when button pressed.

    first_record;
    <<record_loop>>
    loop
      insert into ....
      exit when :system.last_record = 'TRUE';
      next_record;
    end loop record_loop;

    My request for the loop is.

    Select RI_ITEM_CODE from OT_REQ_ITEM

    Where REQ_NO =: field1;

    Please suggest

    Thanks in advance.

    Kind regards

    Afzal.

    Forgive me if I am oversimplifying this, but why not just base your block of data to the table: XXTABLE.  Then, you just put your form in design query (F7). Enter the value of 1122 in the area of the INVOICE_NUM and selects Execute Query (F8).  Then forms does all the work to extract and display the records without having to write code to do this.  This saves you having to write the code to perform and DML as well because the forms will take care of the Insert, Update and Delete automatically when your users click on save or press F10 (if I remember correctly).

    If you must absolutely query and display your data manually, then you cannot use the standard SELECT INTO method because it will only show 1 record.  You need to loop through your recordset and to manually edit the records in your block after you assign a value to the line.  For example:

    
     /* Sample Button Code */
    DECLARE
      v_invoice_num NUMBER := BLOCK.TEXT1;
    
      CURSOR Get_Items (p_invoice NUMBER) IS
      SELECT INVOICE_NUM, ITEM_CODE
      FROM XXTABLE
      WHERE invoice_num = p_invoice;
     BEGIN
      GO_BLOCK('BLOCK');
      CLEAR_BLOCK(NO_VALIDATE);
    
      FOR rec in Get_Items(v_invoice_num) LOOP
      :BLOCK.INVOICE_NUM := rec.invoice_num;
      :BLOCK.ITEM_CODE := rec.item_code;
      Next_Record;
      END LOOP;
     END:
    

    I really don't like this method, but it could work.

    Craig...

  • DB update multiple records in a table with a form

    I'm developing an online proofing system that displays a number of images and then allow the client to approve each image, but also to comment.

    I currently have a configuration table with the different elements (an image dynamically takes its name, details about the image and the required form fields). See this Image for layout

    I would then apply a repeat region (the number of signs vary) and you want to update all records with feedback from the customer and approval with a single form. How this is done? I downloaded a trial of the Toolbox for developers, but the documentation is horrible. I'd be willing to buy an extension that will allow, as appropriate.

    I found an extension that does this in two minutes:

    http://www.WebAssist.com/Professional/products/ProductDetails.asp?pid=117

    Great software, highly recommended. Easy to figure out and got this "problem" solved quickly.

  • Inserting multiple records of a QofQ?

    I do (yet!) an application for the parents to sign up for more information of the school of their child and giving them the opportunity to choose more than one year by using the checkboxes. I am of the grading as a string, then their analysis in different grades available and then query the db to see if subscription E-mail/school/grade already existing. If there is not, I would like to add to the db. Using CFDUMP, I've verfied that I extract the correct records for Add.

    I have appended to the query that selects records to add, then on my current INSERT query (choking on "INSERT") - I tried to put in square brackets the CFWACK INSERTION, but that no longer works. The error is "query of queries syntax error; INSERT met ".

    I have it!

    I had to change the allocation in the dbtype cfquery query to datasource = schoolnotices = INSERT.

    THANK YOU all for your advice. I learn loads and getting better with smaller on the way more problems as big as that. :)

  • PDF form with checkboxes

    Hello

    I created a Board contact with Photoshop or Lightroom. I know that the number of images, lines & columns and their spacing.

    How can I create a script which will add checkboxes under each image?

    The pdf file can contain multiple pages and one of the entries that I will go to the script is the number of images, the line x col + spacing desired images.

    The goal is to send it to the customer and ask them to choose their favorite images, save the doc and send it to me.

    I have some experience with Photoshop scripts, and hope that this is not very different.

    Thank you

    As mentioned, the only part you need to script adds the fields. This can be done using the addField of the Document object.

  • Need help with PHP form with checkboxes, radio buttons and file as an attachment

    Hi guys,.

    I'm having a nightmare with this PHP form where a user can fill it out, attach a doc/pdf and submit. After trying to sort out with the previous code, I used, I have stripped try and think that I should start again just in the hope that you geniuses can help!

    Here is the HTML code of the contact.php:

    <form action="" method="post" name="contact" id="contact">
    
        <p>Job Title:*<br />
        <input name="position" type="text" /></p>
    
        <p>Nationality:*<br />
        <select name="nationality">
          <option value="">-- select one --</option>
          <option value="Afghan">Afghan</option>
          <option value="Albanian">Albanian</option>
          <option value="Algerian">Algerian</option>
          <option value="Zambian">Zambian</option>
          <option value="Zimbabwean">Zimbabwean</option>
        </select>
        </p>
        
        <p>Which country are you currently living in?*<br />
        <select name="country">
        <option value="">-- select one --</option>
        <option value="United Kingdom">United Kingdom</option>
        <option value="Afghanistan">Afghanistan</option>
        <option value="Africa">Africa</option>
        <option value="Zambia">Zambia</option>
        <option value="Zimbabwe">Zimbabwe</option>
        </select>
        </p>
        
        <label class="radio" for="checkRight">Yes/No question?</label><br />
        <input class="radio" type="radio" name="right" value="Yes" /> Yes
        <input class="radio" type="radio" name="right" value="No" /> No
        <input class="radio" type="radio" name="right" value="N/A" /> Not applicable
        
        <p>Yes/No question?<br />
        <select name="continue">
        <option value="">-- select one --</option>
        <option value="Yes">Yes</option>
        <option value="No">No</option>
        </select>
        </p>
        
        <p>Select your resorts:<br />
        Resort 1<input name="res1" type="checkbox" value="Resort 1" />
        Resort 2<input name="res2" type="checkbox" value="Resort 2" />
        Resort 3<input name="res3" type="checkbox" value="Resort 3" />
        Resort 4<input name="res4" type="checkbox" value="Resort 4" />
        Resort 5<input name="res5" type="checkbox" value="Resort 5" />
        Resort 6<input name="res6" type="checkbox" value="Resort 6" />    
        </p>
        
        <p>Don't send form unless this is checked:* <input type="checkbox" name="parttime" value="Yes" /></p>
        
        <p>Date of arrival: <input name="arrive" id="datepick" /><br />
        Date of departure: <input name="depart" id="datepick2" /></p>
        
        <script type="text/javascript" src="assets/scripts/datepickr/datepickr.js"></script>
        <link href="assets/scripts/datepickr/datepickr.css" rel="stylesheet">
        
        <script type="text/javascript">
        new datepickr('datepick');
        new datepickr('datepick2', {
        });
        </script>
        
        
        <p>Name:*<br />
        <input name="name" type="text" /></p>
        
        <p>E-mail:*<br />
        <input name="email" type="text" /></p>
        
        <p>Telephone:*<br />
        <input name="telephone" type="text" class="ctextField" /></p>
        
        <p>Upload CV (Word of PDF formats only):<br />
        <input type="file" name="cv" class="textfield"></p>
        
        <p><input name="submit" value="Submit Enquiry" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    
    </form>
    

    Furthermore, the work of date boxes so excuse Javascript in there!

    To avoid SPAM, I used something where there is a hidden URL field that should be left blank for the form to submit you see in PHP.

    Here's where I am with the PHP which is placed above the heading of contact.php...

    <?php
    
    if (array_key_exists('submit', $_POST)) {
        $position = $_POST['position'];
        $arrive = $_POST['arrive'];
        $nationality = $_POST['nationality'];
        $parttime = $_POST['parttime'];
        $depart = $_POST['depart'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $telephone = $_POST['telephone'];
    
    $to = "[email protected]";
    $subject = "Recruitment Application";
    
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= 'From: My Website <[email protected]>' . "\r\n";
    
    
    
    $message= "
    ";
    
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    }
    
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mywebsite.co.uk/sent.php' );
    }
    
    }
    
    ?>
    

    I would like to make virtually all of the mandatory field so if a field is left empty (other than the hidden URL field), a warning message is displayed next to this field.

    Also, I would like that the file upload field to attach to the e-mail address that is sent to me and the results come through me in a table.

    Can someone help me get my form to work?

    Thank you and I hope to hear from you!

    SM

    Either way, the url of your custom success page must go inside the thanks_page variable:

    $thanks_page [0] = "Success.php";

    Nancy O.

  • to insert multiple records in another table

    Hi all;

    How can I increase the number of records in the table?

    SQL > insert into tab2 to select * From tab1;

    Enter tab2 to select * From tab1

    *

    ERROR on line 1:

    ORA-00926: lack of keyword VALUES

    Hi try this...

    Insert in tab2 select * from tab1

Maybe you are looking for