Populate form with previous data - javascript

I'm looking to add a feature to my application which currently, you enter your first name and last name and a few other details.
What I want to add is the ability to start typing the first name in the form and instantly output those with a similar name and if the name is there then use those details rather than entering the name again.
Once you've selected the name of a previous entry you can carry on adding the data to the form for the fields not populated.
I'm currently working with laravel any insight to tackling this one would be greatly appreciated.
Thanks

I have done this before but not in Laravel. The concepts should be mostly the same. The issue you will run into is how you want to qualify similar. If similar means you can use a "like" query against values the start with what has been typed against a database table, it's super easy. The simple way is going to perform a query like this:
$users = DB::table('users')
->where('name', 'like', 'rob%')
->get();
Because the wildcard is at the end, you can still use a standard database index to prevent your lookups from killing your database.
If you want something more advanced, you'll have to figure out indexing schemes and possibly use a full-text index server like Lucene. We ended up with the latter.
In either case, you will need an API endpoint that works with a front-end widget. I believe we used the JQuery plugin Select2. It has an example to make it work for a remote data set with Ajax.

Related

Is there a way to change an entire columns value in a SharePoint list

I have a simple SharePoint list which consists of 2 columns, username and a Boolean Yes/No expression. It is used for users to acknowledge that they have read a document. I would like to create a button that would set all users Boolean expression back to ‘No’ when the document is amended/updated. Is there a way to do this?
I am very new to SharePoint and have not had a lot of experience with JavaScript. Thanks in advance for any help!
SharePoint does not provide a way to confirm that the user whether has read the document.
As a workaround, you could add a workflow to update the list value ,Users can start the workflow after reading the document.
Can you please explain two columns that you have added are part of the same document library , Or document & two columns in separate list.
If you have idea of JavaScript, then you can write CSOM Javascript code to implement the above scenario. you can also make use of SharePoint REST Calls.
If you have idea of C#, then you can write even receivers to clear off the boolean values based on Document State Changes.

How to auto-populate when checked / remove info when unchecked

I am very new to programming and I need some help. I am making a billing/invoice program. I would like to be able to populate and unpopulated an invoice by checking or unchecking a company and either one or multiple services. The company names and services are being stored in a database. I know this needs to be done with JavaScript. I have been looking for examples of how to do this on the internet and I can't find anything that use checkboxes. I'm probably making this way harder than what it should be. Any help on how I can do this would be greatly appreciated.
Google's first result on "javascript checkbox" is an answer to your struggle (w3schools link).
you need to do it in few steps 1st. If data is stored in SQL database use PHP to transfer data for json or use PHP to insert data stright in to columns(checkbox labels)
2nd. Data is readable, so lest go for next step if you using JSON insert data in to your label's.3rd. Write some code in JS, you need to create few functions like get checkbox val, load invoice , and some more relative to your case. For sure you will have some trouble with writing code, but you have community, and we are here to help :D Good luck

mysql order by field usage/limit/performance

I'm currently trying to modify the selection order of some records using a javascript drag&drop mechanism.
This is the idea:
Once I've ordered the elements by d&d I retrieve the IDs of each element (in the right order) and I send them to php via ajax call.
I store the array of IDs somewhere (to develop)
Then, I run a query like this:
$sql = "SELECT * FROM items ORDER BY field(id, ".$order.");";
(where $order is the imploded array of IDs)
It works quite good but, since I never used this feature before, my doubt is:
since my IDs are strings of 16 characters, and supposing to have 200 records to order....
...Should I expect some trouble in therms of performance?
Do you see any better solution?
Thanks.
The comments up there made me think and I realized that this approach has a big issue.
Even considering to send the $order array only at the end of drag&drop process - I mean, push a button (unlock d&d), reorder, confirm (send&lock) - it would be however necessary to perform a custom select on every single js action comporting a refresh of the elements (view, create, rename,...). And that's pretty dumb.
So I guess that the best approach is the one suggested by Kiko, maybe with a lock system as described above to avoid an ajax call and consequent reindexing of the order field at every single move.

Django - Dynamic number of ModelForms based on dropdown value

I have a form that registers teams of people. Based on a dropdown to select the number of members in the team, the form should show that many model forms, one for each member.
I am not particularly sure what the correct design patter for this is. Here are the solutions that I have come up with:
Use JS to generate the HTML for each member form and then use the Django ModelForm backend to parse each form. However, in this case I cannot use the inbuilt rendering functions of Django and validation notification becomes bothersome.
Send a GET request whenever the user changes the dropdown value, and the GET request specifies the number of members you want to add. But here it would result in any previously entered data being cleared.
Send a POST request via JS whenever the dropdown is updated, and then re-render the form with the appropriate values picked up from the POST request. I am not sure if this is the right way to do this and seems to be easy to get wrong.
Can you please advise on what is the best solution for this scenario?
I am pretty sure this has already been answered somewhere, but I can't seem to find it anywhere. If you have the link to the answer, please go ahead and mark this question as a duplicate.

What does the collection returned by CrmRestKit.RetrieveMultiple look like?

In a form in CRM2011 I am using a JavaScript function to retrieve some attributes from a custom entity unrelated to the one in the form.
I have a successful call to CrmRestKit.RetrieveMultiple but I don't know what the returned collection comprises. Can someone point me in the right direction, please?
To be a little more specific about the requirement: the query returns a set of Field schema names; i.e. the column being queried is in a custom entity and contains schema names of Fields. I want to match each one I retrieve against the calling form's collection of Field-based controls so that I can perform an action on matching ones. Any assistance towards that would also be gratefully received, thanks.
The easiest way I have found to know what you'll be working with is to take the output and run it through JSON.stringify() and write the contents of that out to the page.
For bits like this I usually just debug with IE. That will allow you to add breakpoints and inspect the object.
Related info: Debugging Script with the Developer Tools.

Categories