retrieving information from form

4

4Ankit

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.emailaddress')
}
</script>


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

<body>
<h1> Worldcup 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. (e-mail address removed)" name =
"emailaddress" size = "35" maxlength=
"35"/>
</label>
</P>

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

shimmyshack

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.emailaddress')}

</script>

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

<body>
<h1> Worldcup 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. (e-mail address removed)" 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();" />
 
A

ASM

(e-mail address removed) 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.emailaddress')

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">

<p>
<label>Email Address:
<input type = "text"value="e.g. (e-mail address removed)" name =
"emailaddress" size = "35" maxlength=
"35"/>

<input type="text" value="e.g. (e-mail address removed)"
name="emailaddress" size="35" maxlength="35"/>
</label>
</P>

<input type="button" onclick="changeContent()" value="Change content">

and why not :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top