Jump to content

Recommended Posts

Create a Submission Form to your lookup table

First, we are going to create a Submission Form DataPage so users can submit new records directly to the lookup table.

  • Click New DataPage. By default, the cursor selects Submission Form as the first DataPage type. Click Next.

  • Select your lookup table as the data source. Click Next.

  • You can select which fields to be used in your submission form. To select fields, move the fields from the Available Fields list to the Selected Fields list. Because you are submitting to a lookup table, it is likely that there will only be one (or very few) fields. Click Next.

  • Format the Field as needed, Go to the Advanced Tab and check “on exit to pass field value as parameter”. Note the parameter name as you will use that name in your Javascript. Click Next again.

  • Now on the last page, replace the success message with a JavaScript. This JavaScript will close the popup window and the new dropdown items will be visible. Go to the Source mode and insert the following JavaScript into the message panel:

<script>
window.close();
//Replace the FieldName with the Submission form FieldName(parameter name passed when you checked “on exit”.
var element_value='[@InsertRecordFieldName]'
var new_item = window.opener.document.createElement("option");
new_item.text=element_value;
new_item.value=element_value;
// Add new item to the dropdown
 try 
{
//Replace the FieldName with the Original DataPage dropdown FieldName
window.opener.document.getElementById("InsertRecordFieldName").options.add(new_item, null); 
}
catch(ex) 
{
//Replace the FieldName with the Original DataPage dropdown FieldName
window.opener.document.getElementById("InsertRecordFieldName").options.add(new_item);
}
</script>

  • Click Finish to Save Your DataPage.

Deploy Submission Form

1. Select the Submission Form again and click the Deploy button. In order for the script to work, both DataPages must be embedded in webpages with the same domain name. You can make an empty webpage containing only the following HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
CASPIO DEPLOY CODE
</body>
</html>

2. Replace "CASPIO DEPLOY CODE" with the deploy code of your submission form. If your original form is deployed using the URL deployment method you can deploy the submission form using the same method.

3. Copy the URL of the submission form and save it for use in the next step.

Create a link in your original DataPage

Now in your original form, you add a link that will display a popup window containing the Submission Form from the previous step.

  1. Select the DataPage where you would like to add the link and open the DataPage Wizard by clicking Edit. On the second screen be sure to enable advanced options.

 

  1. Proceed to the Configure Fields screen. Using the Insert button at the lower right of the DataPage Elements panel, add an HTML block. Go to the Source mode and insert the following link code into the HTML panel:

 

<a onclick="window.open('DataPageURL','popup','width=307,height=341,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">Add Option</a>
  1. Replace the DataPage URL portion with the URL of the first Submission Form. Update the other options in this hyperlink as needed.

  2. To move the link to the same line as the dropdown, select the dropdown DataPage element and go to the Advanced tab. Click the Checkbox for Continue next element on same line.

  3. Click Finish to save your DataPage

Link to post
Share on other sites
  • 4 months later...

Hi, I am having trouble with this suggestion.

I have a popup window for creating a new order. In the new order window, I have a dropdown field that has a lookup to my client list. I wanted to create an option that if the client is a new client, my users could click on a link next to that field, to fill out the new client information. And then have that new record pass back as a parameter to the the order window. 

But it doesn't pass back. 

Both pages are located in the same domain.

This is the code in the new client datapage in the success message 

<script>

var element_value ='[@InsertRecordClient_Rec_ID]';
var element_text ='[@InsertRecordName]'; 
var new_item = window.opener.document.createElement("option");
new_item.text = element_text;
new_item.value = element_value;
window.close();

try 
	{
		window.opener.document.getElementsByName('InsertRecordOrder_Client_Rec_ID')[0].options.add(new_item, null); 
	}
catch(ex) 
	{
		window.opener.document.getElementsByName('InsertRecordOrder_Client_Rec_ID')[0].options.add(new_item);
	}

</script>

In the order window, in an html block

<a onclick="window.open('add-client-limited.html' , 'popup', 'width=307,height=341,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">Add Option</a>

I would very much appreciate any suggestions as to what I'm missing. Thank you.

Link to post
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
Reply to this topic...

×   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...