473,503 Members | 9,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieving information from form

hello all, i am having some difficulty retrieving information from my
form. I want to add content in my table but the content i want to add
to the table is what the user inputs in my form.

Basically i want to know how i retrieve information from the form so i
can disaply it in the table.

i have put the code i am using below, the feature i cannot get to work
is the change content function. I want the email address entered by
the user,if the change content button is clicked it copies the email
address in the the top of the table.

Below is the code i am using:

<html>
<head>
<title>retrieve information from form </title>

<script type="text/javascript">
function changeContent()
{
var x=document.getElementById('myTable').rows[0].cells
x[1].innerHTML=document.getElementById('test.emailaddr ess')
}
</script>
<style type="text/css">
strong {font-weight:bolder;
color: powder blue;
font-style:Minion;
font-size:50%};
</style>
<head>

<body>
<h1Worldcup Groups <h1>

<table id="myTable" border="1">
<tr>
<td>Game1</td>
<td>India</td>
</tr>
<tr>
<td>Game2</td>
<td>Pakistan</td>
</tr>
<tr>
<td>Game3</td>
<td>Sri Lanka</td>
</tr>
</table>

<formname = "test">
<p>
<label>Email Address:
<input type = "text"value="e.g. je*********@brunel.ac.uk" name =
"emailaddress" size = "35" maxlength=
"35"/>
</label>
</P>

<input type="button" onclick="changeContent()" value="Change content">
</form>
</body>
</html>

Mar 24 '07 #1
2 1997
On 24 Mar, 13:00, 4An...@gmail.com wrote:
hello all, i am having some difficulty retrieving information from my
form. I want to add content in my table but the content i want to add
to the table is what the user inputs in my form.

Basically i want to know how i retrieve information from the form so i
can disaply it in the table.

i have put the code i am using below, the feature i cannot get to work
is the change content function. I want the email address entered by
the user,if the change content button is clicked it copies the email
address in the the top of the table.

Below is the code i am using:

<html>
<head>
<title>retrieve information from form </title>

<script type="text/javascript">

function changeContent()
{
var x=document.getElementById('myTable').rows[0].cells
x[1].innerHTML=document.getElementById('test.emailaddr ess')}

</script>

<style type="text/css">
strong {font-weight:bolder;
color: powder blue;
font-style:Minion;
font-size:50%};
</style>
<head>

<body>
<h1Worldcup Groups <h1>

<table id="myTable" border="1">

<tr>

<td>Game1</td>

<td>India</td>

</tr>

<tr>

<td>Game2</td>

<td>Pakistan</td>

</tr>

<tr>

<td>Game3</td>

<td>Sri Lanka</td>

</tr>

</table>

<formname = "test">
<p>
<label>Email Address:
<input type = "text"value="e.g. jesuschr...@brunel.ac.uk" name =
"emailaddress" size = "35" maxlength=
"35"/>
</label>
</P>

<input type="button" onclick="changeContent()" value="Change content">
</form>
</body>
</html>
what do you want to do this for? any changes made in this way, or
email addresses entered will be lost once the page is refreshed.
In order to save the data entered you need to use a server side
scripting language like php/python/ruby/perl etc... to save those
changes.

The thing you are doing at the moment, can be done using (although
there's no finesse and there are better ways)

<script type="text/javascript">
function changeContent()
{
var input = document.getElementById('enter_email');
var p = document.getElementById('email');

//add the email into the paragraph
p.innerHTML = input.value;

//if you just want to blank the input afterwards
// input.value = '';
}
</script>
<p id="email"></p>
<input type="text" id="enter_email" size="35" />
<input type="button" onclick="changeContent();" />

Mar 24 '07 #2
ASM
4A****@gmail.com a écrit :
hello all, i am having some difficulty retrieving information from my
form. I want to add content in my table but the content i want to add
to the table is what the user inputs in my form.

Basically i want to know how i retrieve information from the form so i
can disaply it in the table.
var myData = document.myForm.myInput.value;

with :
myForm = name of your form (not the id !)
myInput = name of your text field (not the id !)
i have put the code i am using below, the feature i cannot get to work
is the change content function. I want the email address entered by
the user,if the change content button is clicked it copies the email
address in the the top of the table.

Below is the code i am using:

<html>
<head>
<title>retrieve information from form </title>

<script type="text/javascript">
function changeContent()
{
var x=document.getElementById('myTable').rows[0].cells
x[1].innerHTML=document.getElementById('test.emailaddr ess')
That (getElementById) will not work with firefox because your form and
elements have not an id.
That will not work because you don't call the "value" of the field.

x[1].innerHTML = document.test.emailaddress.value;

x[1].innerHTML = document.forms['test'].elements['emailaddress'].value;

x[1].innerHTML = document.forms[0][0].value;
}
</script>
<table id="myTable" border="1">
<tr>

Take care of spaces in your code !
<formname = "test">
<form name="test">
<p>
<label>Email Address:
<input type = "text"value="e.g. je*********@brunel.ac.uk" name =
"emailaddress" size = "35" maxlength=
"35"/>
<input type="text" value="e.g. je*********@brunel.ac.uk"
name="emailaddress" size="35" maxlength="35"/>
</label>
</P>

<input type="button" onclick="changeContent()" value="Change content">
and why not :

<input type="button" onclick="changeContent()" value="Change content" />
</form>
</body>
</html>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1192
by: Dave Rams | last post by:
Can some one suggest an article on the saving and retrieving VB.net projects. I have lost complete programs at least twice. I have to reconstruct the programs. It has happened when I enter...
0
1186
by: Brian Conway | last post by:
How can I code something to pull a particular cells information in a datagrid and assign it to a variable? I have a button that I want to user to click on, and when they do this it will pull the...
2
15681
by: Sakke | last post by:
Hello! We have written a GCryptoSvr.dll COM server in C++. Inside that resides WebClient COM component. WebClient CLSID is {8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that...
1
1525
by: Captain Dondo | last post by:
I am not really experienced in Javascript so bear with me.... I am working with an embedded platform; no mouse, no keyboard. Just up, down, left, right keys and +/- keys for...
1
9434
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
3
1684
by: BOBss | last post by:
I have an .ASP page that comes up, and I am trying retrieve a variable from the previous .ASP page. However none of the variables from the previous .ASP page are available to the current .ASP page....
0
3366
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
34
2535
by: vpriya6 | last post by:
Hi guys, I am new to Ajax, xml and javascript. I want to know how can I retrieve data from xml and display in the html page? please help me out. suppose my xml file is customer.xml the code...
1
4424
by: fidgen | last post by:
Hiya, I'm trying to get a AJAX driven update to my list of news articles, so when users click the title of the news article, it pops up the article content in a thickbox overlay. Retrieving...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.