468,146 Members | 1,429 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,146 developers. It's quick & easy.

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 1662
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dave Rams | last post: by
reply views Thread by Brian Conway | last post: by
1 post views Thread by Captain Dondo | last post: by
1 post views Thread by jimmyfo | last post: by
30 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.