I'm not much of a web programmer, but I'm creating a simple web app that has a form where the user can enter a series of points (x,y,z) but I don't know how many the user is going to enter. I don't want to guess the probable maximum (100 maybe?) and put 100 fields on the form because it would look ugly. What's the easiest way to add more fields (or unhide fields) as the user enters data without contacting the server.
Currently I'm just using html & php, but I assume to do this I'll need javascript?
Currently my code looks like this, as the user enters data, I want another row to appear.
Any idea the easiest way? Thanks..
Roland RabienRoland Rabien6,54177 gold badges4040 silver badges6262 bronze badges
6 Answers
jjclarksonjjclarkson
4,68755 gold badges3030 silver badges6161 bronze badges
You will most likely have to use javascript, yes. You can use this or write your own using it as a reference:
cakeforcerberuscakeforcerberus3,04255 gold badges2828 silver badges4141 bronze badges
I created soemthing similar and I think it would help you. I used jQuery to create input fields dynamically. Please check this link : Dynamically add form fields
SanjeevSanjeev
harish patelharish patel
What you're saying is that you're hand writing the input tags? Or are you saying that you want a dynamic action where a user clicks a button and it adds more table rows?
In anycase, for your code, you just need a loop, like so. I assume $data is whatever data you want to set based on an array that is probably from the database or something:
Of course you can't copy and past the above, but that's a good starting point.
For dynamically doing it, you can't use php. What it sounds like you want to use is javascript ajax, and php combination.
DanielDaniel
Tejas SavaliyaTejas Savaliya
Not the answer you're looking for? Browse other questions tagged phphtml or ask your own question.
-->Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
A field group is a collection of fields that the system treats as one item. A field group can appear on multiple forms. When you add or remove a field from a field group, the field is immediately added or removed from each form where the field group appears. For more information about field groups, see Defining Field Groups.
To create a field group, you use the Application Object Tree (AOT) to add the field group and its fields to a table. For detailed information about how to create a field group, see How to: Create a Field Group. You also use the AOT to assign the field group to the form where you want the field values to appear.
Php Dynamic Form
Creating and Assigning Field Groups by Using the AOT
The following procedures show how to create a field group and how to add a field group to a form.
To add a field group to a table
- In the AOT, expand Data Dictionary, expand Tables, and then find and expand the table where you want to add a field group.For example, you want to add a field group to the table for customers. Therefore, you find and expand the CustTable node.
- Right-click Field Groups, and then click New Group. The AOT adds a field group named Group1.
- Right-click Group1, and then click Rename. Type a name that uniquely identifies the group.For example, you type MyFieldGroup for the name of the field group that you added to CustTable.
- In the AOT, right-click the Fields node, and then click Open New Window. The list of fields appears in a separate AOT window.
- In the AOT window that shows the list of fields, drag fields from the Fields node onto field group you added in the first AOT window.For example, drag the AccountNum, CreditMax, and CreditRating fields onto the MyFieldGroup node you added to CustTable.
- To save the field group, right-click table, and then click Save.
To add a field group to a form
- Press CTRL+D to open an AOT window, expand the Forms node, and then find the form where you want to add the field group.If you want to create a form, right-click the Forms node, click New Form from template How to sort mods in vortex. , and then click the type of form you want to use.For example, you click New Form from template and then select SimpleList.
- Specify a name that uniquely identifies the form. To change the name, right-click the form, click Rename, and then type a name that uniquely identifies the new form.For example, you right-click the simple list form you created in the previous step, click Rename, and then type MySimpleListForm.
- In the AOT window that shows the table with the field group, click the table and then drag the table onto the Data Sources node of the form.WarningYou cannot drag a field group from a table in the Data Dictionary onto the form or the Design node of the form. You must first add the table that includes the field group to Data Sources node of the form.For example, you drag CustTable onto the Data Sources node of MySimpleListForm.
To add fields to the form
- Expand the form node, expand Designs, and then expand Design.For example, you expand MySimpleListForm, expand Designs, expand Design, and then expand the GridContainer group. You should see the grid control for the simple list form.
- Expand the Data Sources node, right-click the table, and then click Open New Window. The table in the data source appears in a separate AOT window.For example, you expand the Data Sources node of the MySimpleListForm form, right-click CustTable and then click Open New Window.Titles and comments containing spoilers may be removed without notice. Intentional spoilers will result in a ban. Pipboy remover fallout 4.
- In the AOT window that shows the data source table, expand the Fields node and then click the field group you want to appear on the form. Drag the field group onto the Design node or a control in the Design node of the form. A control is added for the field group and for each field in the group.For example, you drag the MyFieldGroup that you added to CustTable onto the grid control of MySimpleListForm. If you expand the grid control you should see a group control named MyFieldGroup. If you expand the group, you should see the controls for the AccountNum, CreditMax, and CreditRating fields.TipUse the DataSource property of the grid control to specify the table in the data source where the field group appears. If you do not specify the data source, the field values will not appear in the grid. For example, you use CustTable to populate the DataSource property of the grid that appears in MySimpleListForm.
- Right-click the form, and then click Save.
To see the fields on the form, right-click the form and then click Open. For example, you right-click MySimpleListForm, and then click Open. The form appears and you can see a list of values for the fields specified by MyFieldGroup.
Access Dynamic Form Adds Fields Online
Announcements: New book: 'Inside Microsoft Dynamics AX 2012 R3' now available. Get your copy at the MS Press Store.