|
|
Subject:
forms and prompts in HTML/Javascript
Category: Computers > Programming Asked by: fieldlily-ga List Price: $10.00 |
Posted:
27 Nov 2005 10:34 PST
Expires: 27 Dec 2005 10:34 PST Question ID: 598159 |
I am trying to make a website that does the following: when a visitor enters text into a form and hits Submit, the website displays that text further down the page (not in a form field; as part of the body text). Is there a way to do this without knowing CGI? For example, can you set up the webpage so that, when the visitor enters text and submits it, that entry gets assigned a JavaScript variable and can be read/used later in the page? As this question probably shows, I am a JavaScript novice, but I am willing to put in some effort if I can get this done w/o CGI/other backend programming. Thanks everybody. | |
| |
| |
|
|
Subject:
Re: forms and prompts in HTML/Javascript
Answered By: palitoy-ga on 28 Nov 2005 03:11 PST Rated: |
Hello fieldlily-ga Thank-you for your question. The solution b_cummins-ga has provided us with a good basis to start on but unfortunately does not work in Firefox (or Mozilla based) browsers. As these now are used by approximately 10% of the people surfing the internet we should make the script compatible. Luckily this is simple to do. The problem with b_cummins-ga's script is the use of innerText which is only fully supported by Internet Explorer. To make it compatible simply change innerText to innerHTML. This makes the example below read: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Change on submit</title> </head> <body> <p>First box:<br /> <input type="text" name="first"><input type="button" value="Submit" onClick="document.all.second.value = document.all.first.value; document.all.inpara.innerHTML = document.all.first.value"> </p> <p>Second box:<br /> <input type="text" name="second"> </p> <p>You typed:<br /><div id="inpara">nothing</div></p> </body> </html> Should you require any further assistance on this matter please do not hesitate to ask for clarification. |
fieldlily-ga
rated this answer:
and gave an additional tip of:
$15.00
Worked like a charm. Thanks very much for an easy and effective solution. |
|
Subject:
Re: forms and prompts in HTML/Javascript
From: b_cummins-ga on 27 Nov 2005 15:19 PST |
try this. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> New Document </title> </head> <body> First box:<br> <input type="text" name="firstBox"><input type="button" value="go" onClick="document.all.secondBox.value = document.all.firstBox.value; document.all.theBody.innerText = document.all.firstBox.value"> <br><br><br> Second box, further down the page:<br> <input type="text" name="secondBox"> <br><br><br> and in the body the word is <b><div id="theBody">not set</div></b> </body> </html> |
Subject:
Re: forms and prompts in HTML/Javascript
From: palitoy-ga on 28 Nov 2005 10:55 PST |
Thank-you for the 5-star rating and generous tip! They are both appreciated. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |