I have low hopes of somebody actually answering that cause of the high level of spoon feeding involved ;-) But then again, I ll give it a shot.
I would like to make a simple form consisting of an input text field, a dropdown list of existing categories and a submit button. The logic would be:
Case 1: User inputs text to the input field and clicks submit. Then code checks if text equals name of existing category. If category name exists then nothing is done and code prompts user that this category exists. If category name does not exist then the entered text is being written in the database as a new category.
Case 2: User leaves input field empty and selects a category from dropdown list of existing categories. Then upon clicking submit, the code would store the category name selected from the dropdown in a variable.
Case 3: User clicks submit without entering any text or selecting any category from dropdown, then code does nothing and prompts for user to retry..
Any help, code or link, would be much appreciated.
Harry
What you are talking about is a relatively easy task. Even when you are new to programming, this should be possible. What you want is a form validation.
I would recommend to call a function on submit like that:
onsubmit='checkForm()'
Put this code in your form tag.
In that function you can check what ever you want to make sure that the form works the way you want it.
You should read this:
http://www.w3schools.com/js/js_form_validation.asp
Related
I don't need any code, I just need the right way to do it.
What I am doing?
Here is the thing. I am making a software for a pharmacy (Drug Store). I have created a tab for shortlist for the drug. See the picture.
enter image description here
What problem I am facing?
In the last column, I have a form field to input drug or add stock. But you can see there are many form fields for so many rows. When I click to "Confirm" button, it's not gonna work cause the table has been generated using loop. So, for all the fields there are same name.
How can I take the value of input field right above the submit button. I mean when I click confirm button it will take same row's input field not others.
How can I do it? No code needed. I am using php codeigniter framework.
Thanks
create one variable like '$i' and increase it and append it on last of input name.as well as give id to submit button and append id with $i.
for eg. name_1,name_2,submit_2,submit_2
when you submit just get the id of submit button. Then get the number from id eg.2,3.take input from the same input variable id. You can do it using ajax. So it will be done without refresh page.
As I am writing my program by PHP programming language and Mysql DB in WordPress CMS, I built a plugin to create and handle a customize form in a special workflow to the needs of our customer.
After form being filled by the user, one of the editor users of the site would check the data of the filled form and validate them.
The screen shot of the validation page that is show to the editor users is like this.
As you see I fetch data of the form from Data Base and print them to the editor users to validate them. At first all the field are display in green background. By using jQuery I give the editor users the ability to click on the filled that has problem and change the color of the field to red. like the below screen shot.
My question is, how could I store the data about which fields are filled with wrong data (The field that are showing with red background) and use this kind of meta data to create an edit page for end user to correct that fields?
Of curse there are a lot of way to do that. The easiest but in my idea not optimize way is to add Boolean fields match to the form fields in Data Base and submitting hidden field according to that Boolean fields to store the information that each field is correct(TRUE) or not correct(FALSE).
The forms that I am working on have about 174 field that most of them are varchar(254). So the size of data that is storing in data base is huge and I don't wanna make it larger.
Ultimately could you please help me. Is there any other way to store the jQuery actions of the editor users and show that stored data to end users.
I am looking for your help.
Bests.
I want the user to select a thumbnail (which the browser will list from a specific folder) and write comments in a text box and then submitted.
Any ideas which way I should go for? Initially I thought to put thumb selection in PHP Variable but that seems not possible.
I am trying to have something like the image below in my PHP page.
(The links are in the comments. I was unable to post them here properly)
Once I enter the keyword and hit the "plus" it should appear in the table, along with the color to the right. The sequence of colors will be predetermined. If I enter a keyword again and hit the "plus" again, the keyword should appear just below the earlier keyword int the table. For the time being I am assuming the table consists of 5 rows and there are less than or equal to 5 keywords.
Also I want to have a submit button at the bottom that when clicked should send all the keywords now present to a PHP file. I have a form with the action attribute set to a PHP file. The table and the keyword input field are to be a part of a form.
I prefer using javascript and not PHP for many complications. Is there a way I can store all the keywords and then send it to the PHP file once the form is submitted?
Any help would be greatly appreciated.
You could:
Build the html form with five text inputs, all stacked on top of one
another (I think using position: absolute).
Place html table underneath inputs.
Place submit button underneath table.
Use javascript to:
hide the four text inputs that aren't currently being used
display the text input and corresponding color in the table when the user presses the +.
hide the current text input and show the next input when the user presses the +.
When user hits submit button, all five input values will be submitted to action='*.php'
I'm working on a website which shows images. Eeach image has just one description which can be edited or added by any user. Accordingly, there are 2 forms: one for adding and the second for inserting at the same page. I displayed the form which I need and hid what I don't by javascript.
My question is how can I prevent the user from leaving the specific form (not all page and the same URL)?
To be clearer, I will tell you the senario precisely
IF (There is no description)
showing adding button
else (there is a description)
showing the description found ih the DB as a paragraph and editing button
Once the user clicks the adding button, a form with a text area for adding will be shown. And the same goes with editing. I WANT TO PREVENT THE USER FROM LEAVING WHEN ONE OF THE FORMS IS SHOWN. Hopfully things are clearer now !
Thanks in Advance!!
I don't really get your question, but you could handle the blur() event to give focus back to the blurred control (focus()). If you want the user to be able to leave a control but within a single form you should check their parents (the one's who triggered the event and the one's who just gained the focus), if they don't have common parent get the focus back. This is working only if there are a single hierarchical level within the form (i.e: every control within the form are siblings), but there are many other ways to do the trick.
Note that you can not prevent the user from leaving the page. You can display however a warning. See this question.