Auto fill HTML Form with custom data - javascript

In my workplace, there is a web based workflow management system. My job is to upload documents to the system and follow up if the relavent department have completed the job. Department people view the documents and change the status from "uploaded" to "Assigned", "Completed", "Rejected" etc.
I have to search the documents every time by entering the date range and clicking on search button in the form.
Is there any way to make a shortcut like something where I don't have to feed the date every time. My requirement is to fill two date fields with today's date and click the search button automatically.
The said system is a simple web page with a form and uses HTTP POST method.
Edit:
In HTML-GET I can pass whatever I want with URL, like on google if I want to search "stackoverflow" I can staright away type the url like "https://www.google.com/search?q=stackoverflow..."
Is such a thing possible in HTML-POST also.

Related

How to Read and update custom field in Marketo

I need to build a voting system in Marketo.
Similar to this page
Here I don't want any form submission to take place. I just want to update some specific custom fields with vote count on clicking voting button.
Here is my plan and you can suggest if any better execution plan if you have
Step 1 - Since we are not taking email address, we will create one dummy email address and update all voting count to this contacts custom field.
Please note this is purely for voting count and nothing else.
Step 2 - read the custom field values before submitting the new value using below rest API
https://Marketo-end-point-url/rest/v1/leads.json?filterType=id&filterValues=<dummy_email_address_id>&access_token=&fields=Customfield1, Customfield2, Customfield3
Here I am not sure whether we can show access_token in landing page source code or in jQuery files. It might lead to data hack. open for suggestions.
Step 3 - After reading the Customfield data, increment the count by "+1" and update it using rest api.
Thank you in advance.

render partial view based on user permissions

My Task is to create a permission system that is not pre-defined by roles. E.g the system does not define the roles which an admin can assign to other users.
Instead the system only provides all the database tables and the admin can create their own roles on the fly be choosing tables and the grant level (CRUD) and also which fields should be visible. That would be the easy part.
The current implementation without any permissions is to fetch the data with an RESTful API and then create the DOM by javascript. Since the javascript knows what to display on the current page it can grab the properties from the data object or even fetch related data.
But now the returned fields from the API call may be different from user to user. How can i display only the data a user is granted to see?
Example:
In the image below we see the current element only showing the name and description fields. These can the current user edit. There is also a position input to define the ordering of the image but the user has no permission to change that and it is not generated.
Initial state, data fetched from API
When we click on "new image" a new row is added with javascript but now the field "position" is visible.
After clicking "new image"
The JS code does not now what fields the user can see and what not. How can i control that behavior?
Should i create a new API that will fetch the "structure" of the page based on the current users permission or should i alter the javascript code with php to output only required logic for the current user?
What should be the general approach and is there already something available in cakephp?
my current solution is to make a request to a new endpoint which gives me an empty data object but only with fields visible to the user.
button event ->
fetch api/newEmptyObject ->
render input fields
the downside is that it adds a delay from user click-event to displaying the input fields.

php- processing two related forms on same page

I'm new to php and have read lots of posts here in SO but couldn't find an answer for my specific question.
I have a database in which I store information about projects (project name, start date, status, etc...). I'm trying to create an updating api, so the user can update the project info.
What I would like to do is to let the user choose a project from a regular html "select". Once the user chose the project I would like to display a new form containing all the fields that the user can update. The issue is that I would like to have all the project current information (before the update) as values of the form. (So I must send the user selected project name and get back all the info in order to display it on the second form).
For example: let's say that there are 2 possible project statuses: "on execution" and "frozen", then I would like to put as "selected" the current status, and let the user change it if he wants to and then send the second form so I can update the db info.
I would like to know what is the best way to implement that. Solutions can contain javascript if needed.
Thank you in advance for your time and pacience.

Javascript control page and user view page

Currently I'm working on a project where a user enters a lot of data constantly for a hour long window. I'm looking to have one user control all the data via some control panel and then have a link they can distribute to other users that will allow them to view that data without the ability to edit it.
Right now I'm doing some extremely weird methods. I have an XHR request on the control page that fires whenever a field is finished being edited. From there the data is sent to a php file that converts the data into a simple text file. Then the distributed link file will load that file one time and translate it into the necessary format.
Some potential problems I've run into are it seems odd that I'm sending starting as javascript data then going to a php file then to a text file then translating the data all the way back into javascript data again. Another problem I've come into is I'm not sure of a way to force users to reload the page when a field is edited in the control panel after the user has opened the view page.
Have I totally gone overboard here? What are some better concepts I could employ to accomplish this task?
If i understand what you want to do this is how i will do this:
First the data entry
if you have lot of fields you better use a form wizard, i don't have a particular one in mind right now but there is lot of them just search jQuery Form wizard
Here is an example:
http://i.stack.imgur.com/Luk2b.jpg
The concept of the form wizard is to guide user via multiple page and also validate the data. And click save when and the end.
Then save date in database.
Display content
All you need to do is to create a global separate page to display your content.
Let see something like: http://yourserver.com/view/{id}
where id is the identifier of the particular row in your database.
i'm not sure if i totally understand what u about to do. i'm trying to make your work description shorter here:
want to build a website that one person can edit a single page's content in 1 hour, and others can view the content change in that 1 hour.
if this is what u want to build, here's the module:
teacher: the one who can edit the page
student: the one who can only view the page
server: information center
teacher client edits page -> teacher client sends update data to server -> server saves data -> server sends update notice to student client -> student client receives update notice -> student fetches update data from server
to make this module work well, i suggest try socket instead of http reqeust, just like online games or IMs do.
well, try socket.io

Twitter-like tweet box?

so what I'm hoping to do is having a box that's similar to the tweet box. When the user enters '#' (I know, use keyup to detect when), and then he types a letter (i.e. 'J'), I want to get 4 of the people he's following and show it as a suggestion (i.e. James, Jay, Jack, etc...). The way I would approach this is make an AJAX call which will query the sql table to find all of the users whom the user follows and whose names begin with that substring, but what I've noticed that FB does with friends is that it loads all of the user's friends upon visit, meaning that if you were to type '#' then it would scour a client-side array rather than constantly query the database. Although I'm not so sure if that's better... Is it better? Also, when would I load all of the user's following users? As soon as he/she visits any page? And is it conventional?
tl;dr - Should users that a logged-in user be pre-loaded and stored as an array or constantly obtained by querying the database?
Thanks.
When an ajax call has been sent to server a thread is generated in Server's CPU. So if you have 10 user on line search for a friend list it will consume more CPU.
So better option is that fetch list in group. e.g. you want to search Arjun,
If you type A, it will fetch list of all friend with name A. so when you type R(second letter) it will not send ajax request again.

Categories