I am building a media tracker for TV shows and movies.
When the user makes a query on the front-end, on the server I make a request with an API in which I get TV shows/movies with id, title, image link, media type, seasons, etc.
After that, I display the result of the query on the front-end with the name and image:
Then the user can select one of the results and get a simple form:
The thing is that after submitting the form, I want to save the score and progress with the id, media type and other parameters that aren't shown on the front-end but are related to the media submitted. At the moment I am using to pass the values to the server:
<input type="hidden" name="id" value="{{media.response.id}}">
The problem with this is that the user could change the id value with the developer tool (inspector), which would cause problems. I don't really know how to validate the form as the id could be any number.
Is there a better and still simple approach? Thanks in advance
Related
I am new to Zabbix.
Trying to create Web Scenario that verifies web login with ViewState.
so trying to query VIEWSTATE from a login page with regex (so I can pass it when I am logging in) like this:
regex:id="__VIEWSTATE\" value="(.*)
This is what I am trying to query:
<input type="hidden" name="__VIEWSTATE" value="5000_character_long_hash">
Questions:
Is this the correct way of doing authentications that require VIEWSTATE hash to be passed with the login? or is there some other method?
Is my regex correct?
How can I easily verify if Zabbix took my regex correctly?
How can I see the output of {VIEWSTATE} variable?
Passing variables from a step to another, in Web Scenario is currently not possible.
There is also no way of knowing if your regexp is correct, because Web Scenario doesn't output anything like that: its only output are speed, error condition, and if a hardcoded string was found.
You also can not use dependent items, or HTTP Client item. So, you need to create an external check.
I have a field in my website where I want users to enter book names that they can checkout from the database. I want it so that when they start typing the names I want suggestions or drop down under the input box matching the name of the book they are typing.
Is it possible to achieve something like this? I have a books table in my MySQL database and I am using Nodejs as my backend. I have searched a lot online but did not find anything related to this online. Therefore, I decided to ask the question here.
You have to send AJAX request with type GET and send the typed character to the Backend.
and in backend you have to do query for ex :select * from book where name like %input%
Then you have to return the result as an array to the front-end.
Finally, in your front-end code you have to render the result array under the input.
Also, you can use any ready jquery plugin to do this task in front-end code.
The UI element is commonly called a "typeahead" or autocomplete.
Twitter release their frontend component as a jQuery plugin called typeahead.js. Most frontend frameworks will have an equivalent plugin or component.
The backend datasource for the books is up to you to implement.
For small datasets you can render the required book data within the page so it is directly accessible from your javascript.
For large datasets you will probably need to create a backend "book search" service in Nodejs. Typeahead libraries can send that user input to a URL via an AJAX request and the service returns the matching results, usually as a JSON object.
Code for geek example for your stack.
You can make a drop-down menu with book names and using ajax you can get value from the input and search in database and display data .
I suggest you to use mongo db as database.
You can find tutorials in w3 schools or
in malayalam https://www.youtube.com/c/Crossroadstalk
I have an ExpressionEngine site that I'm building with Bootstrap. It's a site for volunteers to find projects to help with. On the home page I have a modal with a form for them to select when they're available and what categories of jobs they're looking for. Then they can click submit and it'll go to a new page with filtered entries.
I don't know if this is possible using the GET method or POST method on the form. I've figured out how to use the GET method and get a query string into my URL but I don't know how to use that data to filter my entries on the entries page. Or would using POST and JSON be a better option? I don't know really how to implement either so any help would be great.
Thanks a lot!
It depends on how the information you would like to show is stored.
If you are using MySQL (a common RDMS), or any other form of SQL Database for that matter, the most common way is to send your GET query string (for example) to your server, have a sever-side language (such as PHP) handle that request by accessing your database, and then echo the result. This can be done synchronously, or with AJAX.
For example, the flow of everything might look like this:
User selects an option (say, "Gardening Projects").
JavaScript converts the value of that input option to a query string and sends an HTTP request using the GET method.
The destination of this request is "filter.php" (for example).
"filter.php" access your database using an SQL query, which searches for any entries in your database, say, having a tag of "gardening".
"filter.php" echos a statement with those entries (or, better yet, returns a JSON object)
JavaScript then parses the resultant JSON object into the DOM, which displays as a bunch of links in a result area that your user can click on.
The question you have about how to handle this is very broad, so I would recommend simply doing some Google searches or looking around this site for resources that show you how to set up databases, access those databases with possibly PHP/SQL, and maybe even use AJAX to return those results, etc.
To get you started (these are in no particular order):
AJAX Tutorial
PHP - JSON encode
SQL tutorial
jQuery AJAX
I got it figured out with some help from #JoshBeam. It turns out that I was trying to make it way more complicated than it actually is. Rookie mistake. In the end I just ended up using method=get in my form and the setting the action as the page with the filtered entries. I then used php to echo the inputs into my EE channel:entries tag.
One thing I still haven't figured out is how to make it so that my query string will combine values for matching names. Currently I have checkboxes for days of the week, each with name="day" and different values for each day. If there are multiple checked, my query string becomes example.com/?day=sun&day=mon when I'd rather have it as example.com/?day=sun&mon. So if anyone has any tips on that, I'd welcome them! I also wonder if there's a way to add pipes between each value when I echo them in my EE tag so that I can have multiples - e.g. {exp:channel:entries category="1|2|3"}. But I have really yet to Google either of these questions so I'll do that.
Thanks!
I'm not sure how to ask this.
I have a HTML form that has several fields, including user id, which maps to a real name. I have jQuery validation of the form working.
Right now, I have to submit the POST request, to show the user's real name.
example: It should show "john doe" if the user types "3", before without clicking submit.
ID input: [3] ( john doe )
Do I use jQuery to retrieve this information? Do I also set up a new page, that has a response to a POST request, that returns 'john doe' as XML / JSON or something along those lines?
note: Using python's Flask. Maybe I should use Flask-Sijax ?
The Flask documentation has a good example using jquery to fetch a value from the server without posting the whole page.
If you wanted it to fire as a user types the number (rather then hitting a button in the example) you could use the .keyup event in jQuery instead of the .bind/click event shown the example.
I am trying to validate that a username is unique on a registration form and would like to verify the uniqueness of the username right after the client types it as opposed to performing this server side after the form has been submitted.
Should I collect a resultSet from the database, store it in an array and then pass this along to the jsp page in the form of a bean (I am using a model 2 design so the user passes through a servlet before arriving at the jsp page)? What if the array is very large? How do I bring this data into javascript?
Alternatively, is there a way to do the query using ajax and javascript all on the client side? Maybe its possible to somehow run the query in the background?
I am really just looking for some direction because I am clueless as to what to even begin researching something like this. Is this even a smart move, performance wise?
I'd use "AJAX" for this.
Here's one approach: set up a blur() handler on the username text field of your form. When the blur() method is invoked, you post the username to the backend code; it verifies it and returns some appropriate response. You then parse the response and change the CSS class on the username text field (e.g., turning it red) -- or do whatever else visually you want to do to indicate "username in use."
Either way, you've got to get the username from the client to the server for verification; you wouldn't want any mechanism which allowed the client to directly use the DB (think security/exploits/etc).
If you're not already familiar, check out jQuery (http://jquery.com/) to make your client-side life much easier.