Jump to content
  • 0

Create Multiple Subforms From Parent Form


financemy

Question

Hi there,

 

I've got an application that allows for a company to self-register to a service.  All company-relevant information goes into the Companies table and they can edit this as needed.  This functionality is pretty straightforward in Caspio, but now I want to extend it.

 

I'd like to capture details on the company directors during the registration process.  The intent would be to have a dropdown asking for the number of company directors, and then provide a form (or forms) to gather the name, email, contact details etc of each one (either all together or consecutively).  These details will go into a table cleverly called Directors, and these new records will include a foreign key for the company record.

 

I've searched the help topics and forum pages with no joy on this.  I did have the idea of using javascript to pick up a "num_directors" parameter passed into a data page, then build N sets of submission forms that would be needed, then use javascript again to submit each form consecutively ... maybe even using multiple published iframes on the data page ... but haven't tested any of these

 

Does anyone have any suggestions on how this could be accomplished?  I've got a second application that needs the same style of approach too

 

Thanks

Mark

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi Mark,

 

If the number of directors is limited, for example number is 4, you can follow the following steps:

1) Add to the table 4 fields: director1, director2, director3, director4.
2) Edit your report and navigate to the 'Configure Results Page Fields' step.
3) Create the 'Rule 1' rule: if the 'num_directors' value less than '4', the 'director4' field should be hidden.
4) Create the 'Rule 2' rule: if the 'num_directors' value less than '3', the 'director3' field should be hidden.

5) Create the 'Rule 3' rule: if the 'num_directors' value less than '2', the 'director2' field should be hidden.

6) Create the 'Rule 4' rule: if the 'num_directors' value less than '1', the 'director1' field should be hidden.

 

Hope it helps.   

Link to comment
Share on other sites

  • 0

Hey Iren, thanks for the reply.

 

I'd much rather keep the directors in a separate table and use a foreign key to join - much better database and programming practice.   The number of directors can vary - from 1 up to 5.  Imagine if they were employees instead - there could be anywhere from 1 to hundreds per company and that would make a flat file pretty difficult to manager

 

Cheers

Marl

Link to comment
Share on other sites

  • 0

I don't know how to do it all at once, but I have a similar situation and I use the following approach.

 

You need three HTML docs and two webpages.

1) viewCompany.html (my example is showing people)

...
<script>
//set iframe source

//I've noticed inconsistencies with iframes unless I set the source at the end
  function setIfrSrc() {
    var varCompanyID = document.getElementById('companyID').value;
    document.getElementById('ifrDirectors').src = 'directors.html?companyID='+varCompanyID;
  }
</script>

...
<body onLoad="setIfrSrc()">
<div>
  <script ...CaspioDataPage ...></script> <!-- this contains id="companyID" -->
</div>
...
<div id="frmDirectors">
  <div class="divHeader">
    <h2>People</h2>
    <a onclick="popupWindow('addDirector.html')"></a>
  </div>
  <iframe name="ifrDirectors" id="ifrDirectors"></iframe>
</div>
...

2) directors.html (Tabular Report)
  

3) addDirector.html (the popup submission form)

...
<script>
// refresh the iframe on the viewCompany.html
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.ifrDirectors.location.reload();
    }
</script>

...
<div>
  <script ...CaspioDataPage...></script>
</div>
...

NOTE:  I don't know when the an autonumber or auto value populate, but I would be worried about unique ID creation with multiple submission pages open at once.

 

Hope it Helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...