This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
AUTO INCREMENT FIELD
Started 16 years ago by dennisturner | 5 posts |
-
Is there any way to add an auto incrementing numeric field to a form? One that could be used for an invoice number or receipt number.
Posted 16 years ago # -
you can set the default value of a field to be that of a session variable
Posted 16 years ago # -
Hi ..
you can make some modification on "includes/view-functions.php" files to make auto increment value, try to insert this code in line 38 - 39
I assume, you want to get auto increment value in form_1 in element_1. You also can make your own invoice number logic to that code :)
//get auto increment value $query = "SELECT max(element_1) max_id FROM ap_form_{$_GET['id']} "; $result = do_query($query); $autoValue = 1; while($row = do_fetch_result($result)){ $autoValue = $row['max_id'] + 1; } if ($element->id == '1' && $_GET['id'] == 1 ) $element->default_value = $autoValue; else $element->default_value = $element->default_value;
MachForm Support
Posted 16 years ago # -
Thanks. I have entered this code and posted to my site. I guess I need to read more about PHP to learn how to implement this information. I put the auto increment field as the first field on my form. But It does not get show on the page with the number. Obviously there is something that I am not doing correctly.
I also tried to set a different fields defualt value to: [#{entry_no}]. Since this value would work - I used the format needed for the email setup. This did not work either.
Posted 16 years ago # -
is there any error message show in your page? I have try that code on my server and it works fine. can you show me the url of your machform ?
or maybe you can send me "view-functions.php" file to customer.service[at]appnitro.com, I will check it for you
MachForm Support
Posted 16 years ago #
Reply
You must log in to post.