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

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)

Related

Can Go capture a click event in an HTML document it is serving?

I am writing a program for managing an inventory. It serves up html based on records from a postresql database, or writes to the database using html forms.
Different functions (adding records, searching, etc.) are accessible using <a></a> tags or form submits, which in turn call functions using http.HandleFunc(), functions then generate queries, parse results and render these to html templates.
The search function renders query results to an html table. To keep the search results page ideally usable and uncluttered I intent to provide only the most relevant information there. However, since there are many more details stored in the database, I need a way to access that information too. In order to do that I wanted to have each table row clickable, displaying the details of the selected record in a status area at the bottom or side of the page for instance.
I could try to follow the pattern that works for running the other functions, that is use <a></a> tags and http.HandleFunc() to render new content but this isn't exactly what I want for a couple of reasons.
First: There should be no need to navigate away from the search result page to view the additional details; there are not so many details that a single record's full data should not be able to be rendered on the same page as the search results.
Second: I want the whole row clickable, not merely the text within a table cell, which is what the <a></a> tags get me.
Using the id returned from the database in an attribute, as in <div id="search-result-row-id-{{.ID}}"></div> I am able to work with individual records but I have yet to find a way to then capture a click in Go.
Before I run off and write this in javascript, does anyone know of a way to do this strictly in Go? I am not particularly adverse to using the tried-and-true js methods but I am curious to see if it could be done without it.
does anyone know of a way to do this strictly in Go?
As others have indicated in the comments, no, Go cannot capture the event in the browser.
For that you will need to use some JavaScript to send to the server (where Go runs) the web request for more information.
You could also push all the required information to the browser when you first serve the page and hide/show it based on CSS/JavaScript event but again, that's just regular web development and nothing to do with Go.

HTML Form: Can submitted GET/POST parameters be suppressed using only HTML or CSS?

I am volunteering on a website-based project that is trying to make all pages fully operable JavaScript free before adding any JavaScript for enhancements, and I was asked to investigate whether or not a particular scenario could be handled purely through HTML/CSS.
What we have is a form that is populated to help us filter a list of tickets that are displayed on the screen after a page update through a GET action, which itself works fine, but the concern with the current implementation is that the URL cannot be made into a permanent link. The request, however, to keep the permanent link as minimal as possible, is to only send GET parameters for fields that are populated with something (so, suppressing GET parameters for fields that are blank) instead of having a different GET parameter for each form field on the page.
I have thought of several ways that could be done, most including JavaScript (example: create fields with ids but no names and a hidden field w/ name that uses JS to grab the data from the fields), but also one that would be a POST action with a redirect back to the GET with a human readable string that could be permanently used. The lead dev, however would prefer not to go through the POST/redirect method if at all possible.
That being said, I'm trying to make sure I cover all my bases and ask experts their thoughts on this before I strongly push for the POST/redirect solution: Is there a way using only HTML & CSS to directly suppress GET parameters of a form for fields that are blank without using a POST/redirect?
No, suppressing fields from being submitted in an HTML form with method of "GET" is not possible without using JavaScript, or instead submitting the form with a POST method and using a server side function to minimize the form.
What fields are submitted are defined by the HTML specification and HTML and CSS alone cannot modify this behavior and still have the browser be compliant with the standards.
No, you cannot programmatically suppress any default browser behavior without using some kind of client scripting language, like JavaScript.
As a side note, you say "JavaScript for enhancements", but JavaScript is not used for enhancements these days. And no one in the real world would except a decent front-end without the use of JavaScript. I would suggest you simply use JavaScript.
I do not think you can avoid Javascript here to pre process before submission to eliminate unchanged /empty form fields.

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

HTML Multiple Form Actions/Outcomes

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.

Methods to copy form values from one form to another?

I need to copy values from a form displayed in one HTML page (incoming.html) to another HTML page (outgoing.html) in a browser. What will be the best approach to this, I have tried using imacros but have not been able to figure it out. I believe there can be a javascript solution to the above. What can be the best approach, I need the feature in a prototype and hence efficiency does not matter.
The best option would be to use a server scripting language. You can pass values between two HTML pages in 2 ways.
First, storing them in cookies using Javascript. If cookies are not enabled, then it would be a problem.
Second, Passing Values through the URL like PHP, but this method is not very secure if your using information that you do not want the user to view.
For eg:
a href='something.htm?Something=Passing some variables'
You can fetch them in the next page using Javascript and display them.