I have a form in which there are multiple fields. The user can enter in any of the field and submit it to the database. I then display display this data in the table.
I have created backend APIs and they are working properly. I also know how to create a component on react, but I am not able to figure out how to display the data in the table after the search button is pressed.
Look at controlled input in React. Basically you need to update the state and use the state value in React for the value of the input
Related
I am trying to filter products in React based on the category which is stored in NodeJs. The search using input is working as it should, but when I try to filter them using a button it only filters the first button (ex: Tart), and once I click on another button all the products disappear and nothing shows until I refresh the page. I have been trying for two days and I can't figure it out.
Fetch data enter image description here
Input filter and button filter enter image description here
categories enter image description here
products enter image description here
The problem here seems to be that you are using filteredProducts instead of using the state that you have assigned the value using setProduct i.e., product.
You should do product.map(x)=>{...} instead.
And next time you post a question, please ensure that you are giving your code in text form instead of images as it's not really easy to read it otherwise.
We are planning to build a dynamic frontend where users (admin specifically) can create UI components with something simple like a button click without changing the code.
For example:-
I have a form where I have 2 inputs username and email and there's a button to add more input fields and whenever the admin clicks on that button it displays another form where you can enter info such as type, label, name of the input field to be added and it then it displays it on the DOM.
But he also wants to persist the newly created form (or components) so whenever other user logs in he'll also be able to see it
We are using react to create our frontend so is there any way to achieve this?
One solution came to my mind that we can store the information to create new components into a database and then fetch that with an API into the component we want and then render it. But they don't want to use a database
I have implemented the React Dual Listbox library in my project. I have a update employee detail form where in the Listbox right hand side table, I need to show the items the user had selected previously while submitting basic detail form.
Now whenever I open the update form, I call an api which gives me the data (in my case a list of items) which user has selected previously while submitting the form. I use this data to prefill the react dual listbox right hand side table which shows the selected items. But, I am not able to prefill it.
I used the selected attribute of the <DualListBox> tag by storing the array of items from the api into the selected array, but still was not able to show the prefilled data.
Please refer React Dual Listbox
How can I show the prefilled data?
I am very new to react. Maybe this is a very simple question. I have a data table with mock data using react data table. How to make table cell clickable and get the data after clicking to display the details on that form? Both form and data table are in the same page.
Here is the link https://codesandbox.io/s/react-table-onclick-row-to-display-data-on-form-unsolved-3636s?
I modified the sandbox here stating how to do this, basically you need a state to store the activeRow;
I have a little form with php and javascript. It's a simple form with radio buttons and a couple of text boxes. Under the form there's a table , which is showing the values from the DB.
The php is taking the values of the text boxes and radio buttons and creating a special URL, which is the "Forwarder" in the picture below.
Now when I press the "Edit" button in the table, it must populate the current record with the values of text boxes and radio buttons into the form, so I can edit the values, creating another URL and update the record. The problem is, I don't know how to do it. There can be many records in the table. I don't know how to populate the form with the current record values. And I can't create a table in the DB for each of the values either.
Please can anybody give me some advice ? I will be very thankful.
Thanks beforehand.
On edit click you can run a select query based on the ID of the record. I see you are displaying it, so just grab the text of the ID field from the table. And we assume you have already saved the data from the form above...
Just create a page that gathers the information, and input fields to the table. I'm not sure if fields are static or not, but just populate all the fields manually.
Then have form set to GET type and on submit will be sent by url to the handler page where you could have Query String with PHP so for example index.php?title=TITLE&field1=VALUE
then use $_GET['title] and $_GET['field1'] to grab the information, grab them fields and save back to database.