HTML Multiple Form Actions/Outcomes - html

Basically Im trying to build a page menu but in the form of a "Search users..." box. So basically when user enters the text "John Smith" the action="JohnSmith.html" but if they type "Mary Smith" the action would ="MarySmith.html".
From what I've been told so far there can only be one action per . Would what I wan't be possible using only HTML, If not how could I go about making this "Search User/Page Selector"?
Thanks!

Before you submit your form you can change the action depending upon the value of your text box in a java script function.
if(textboxValue=='John Smith'){
document.form.action="Action1";
}else if(textboxValue=='Mary Smith'){
document.form.action="Action1";
}
document.form.submit();

HTML marks up documents. It's a markup language. When browsers hit the markers, the HTML tags, they respond. By itself, HTML will not be readily usable to process data conditionally. Another program will be needed to process the HTML form. For these reasons, I suggest, No, HTML will not be a good choice for this task.
PHP, ASP, JSP or maybe even javascript would be good choices for processing form data. A stronger answer would require more structure to the question. Thanks.

Related

Using various inputs of a form in mailto-body

I'm helping someone set up a website, and we're limited to only CSS and HTML. No JavaScript, PHP, or other tools.
We're setting up a simple mailto: form (knowing very well this is old and obsolete), and part of it is working fine. Setting the subject with name="subject" and the body with name="body" allows submitting the text-input and the textarea-input to Outlook from a submit-button.
Now, we're trying to add a dropdown list to the form, so the user can choose the type of request to be handled, adding this to the body of the mail; but have no clue as to how to do this without recurring to a third language.
tl;dr: How to append a string to a GET form without adding a new & in raw HTML?
Any help will be appreciated.
This link provides some guidance as to how the link should look, setting each form input to a new line of the body parameter: mailto link multiple body lines
That can't be done.
If you're going to process the data from the form you need a language other than css and html.
HTML & CSS are simple languages. They aren't able to process information, rather they are instructions which are processed by the browsers.
You will need some kind of traditional/scripting language if you're going to retrieve & work with the data from the web-form.

Contact form HTML, Returning a "Success" text in the .html file

i have this question and i can't find a solution. I'm pretty new in the programming. So..
my HTML file with the form is contact.html (straight html file)
The php code is in separated file. So, everythings work fine, but..
I want to have the return text for the "success" or "fail" in the in my html file (let's say under the submit button). Is it possible if it's not php file with html code, but straight html. And can you tell me what should I do?
I hope you understand me.
Straight HTML can't give different content conditionally.
You could get something that resembles what you describe by placing an iframe after the form and targeting it with the form. As solutions go, that's rather ugly.
You could use JavaScript to send the form data to the PHP file and then modify the DOM of the HTML document based on the response (Ajax), but that would be unnecessarily complex and violate the best practise of unobtrusive JavaScript.
The usual approach to this problem is to have a PHP file being the single entry point for all things relating to the form (it can keep parts of its logic or HTML in other files and include() them as needed) and have it decide, based on what input receives, if it should show:
The plain form
The form with error messages (and pre-populated with the user's incorrect submitted data)
The thank-you

How does HTML form function?

How does HTML form function? and what I mean by that question is not what a form does (It sends the information of all the input elements to the server), but I mean "How does the form know what to do"? Isn't HTML just a mark-up language, which means that it's not for programming? Is there some code hidden somewhere?
I hope it was clear ;)
HTML is processed by the browser, and the browser has programming which "makes the form work". All the form really does though (for most standard uses), is collect the user input and provide it as a POST request to the HTTP server.
Its just part of the web browser to serialize the contents of the input fields and send that up to the server.

Is Form Tag Necessary in AJAX Web Application?

I read some AJAX-Form tutorial like this. The tag form is used in HTML code. However, I believed that it is not necessary. Since we send HTTP request through XmlHttpRequest, the sent data can be anything, not necessary input in form.
So, is there any reason to have form tag in HTML for AJAX application?
Apart from progressive enhancement as already discussed (don't make your site require JavaScript until it really has to), a <form> with onsubmit would be necessary to reliably catch an Enter keypress submission.
(Sure, you can try trapping keypresses on separate form fields, but it's fiddly, fragile and will never 100% reproduce the browser's native behaviour over what constitutes a form submission.)
Sometimes, web apps using ajax to transform their data either use forms as a fallback when the user has no JavaScript enabled (a sometimes expensive but very good thing to do).
Otherwise, if an application builds and sends an AJAX request, there is no compelling reason to use a form except in rare special cases when you actually need a form element. Off the top of my head:
when using jQuery's form serialize function
when monitoring all fields in a form for changes
when there is need to make use of the reset form button (that to my knowledge is available in a proper <form> only).
I see at least two possible reasons :
Graceful degradation (see also Unobtrusive JavaScript) : if a user doesn't have Javascript enabled in his browser, your website should still work, with plain-old HTML.
Behavior of the browser : users know what forms look like and how they behave (auto-completion, error-correction, ...) ; it's best not going too far away from that
And I would add that, if you want the user to input some data, that's why <form> and <input> tags exist ;-)
Using the right tags also helps users -- as an example, think about blind users who are navigating with some specific software : those software will probably have a specific behavior for forms an input fields.
It really depends what you're doing. If you're wanting to take form content submitted by the user and use AJAX to send that somewhere then you're going to want to use the form tag so your user can enter their data somewhere.
There will be other times when you're not sending data from a form and in that case, you wont have a form to be concerned about :)

How can I send information from one html page to another?

I want to create an html page which contains a text box. When I am given input and the Enter key is pressed, I want it to go to another html page and display the typed keyword.
How can I do this?
I think you need to use a server-side scripting language to facilitate the manipulation of the inputted data on the form, so that it gets "saved" and displayed in the other html page. I suggest you try reading about PHP, and then turn to handling information in Web Forms...just a thought!
You can use Javascript for that. Check this Tutorial : How do I pass variables between two pages? (GET method)