Click to See Complete Forum and Search --> : Collecting data from input text boxes and displaying it in the table


sharapov
04-03-2003, 02:27 PM
Hello.

Let's say I grab data from database and displaying it in the input text boxes. When user presses on the button I want to grab the data from those textboxes and display it in the table that will be generated in the new opened window. I can collect the data from input text boxes with the code similar to the one below. But how can I then grab that info and place it inside the table in the new window. Can anybody help?


<script>
function cycle() {
var aData = '';
for (var i = 0; i<document.pricesform.elements.length; i++) {
if ((document.pricesform.elements[i].type == 'text') || (document.pricesform.elements[i].type == 'hidden')) {
aData += document.pricesform.elements[i].value + ',';
}
}
alert(aData);
}
</script>

<form name="pricesform">
<input type="text" name="myTextA" value="apple" size="20">
<input type="text" name="myTextB" value="orange" size="20">
<input type="text" name="myTextC" value="banana" size="20">
<br>
<input type="text" name="myTextD" value="pear" size="20">
<input type="text" name="myTextE" value="peach" size="20">
<input type="text" name="myTextF" value="grape" size="20">
<br>
<input type="hidden" name="myTextG" value="pumpkin" size="20">
<input type="hidden" name="myTextH" value="cranberry" size="20">
<input type="hidden" name="myTextI" value="tomato" size="20">
<input type="button" onClick="cycle()" value="Check">
</form>

rogers
08-29-2003, 10:17 AM
I also have a similar question. Did you figure out how to do this? If so please contact me.

Thanks

zachzach
09-12-2003, 07:19 PM
newindow.document.write("<table><P>" + document.inputFORM1.value + "</p></table>")


hope thats what you wanted
zach

rogers
09-12-2003, 07:34 PM
Actually I have a form which contains 2 text fields. The form also contains a table which has up to 10 rows or so.
The table has 3 columns. The first 2 have data in them, and the third has a button. When the user clicks the button on any given row of the table, the data from the first column of that row should be copied into the first text field.

Let me know if that is possible.

pcolafl
09-12-2003, 08:21 PM
try something like this



<script>
function NOTEXT(form)
{
form.value += ("")
}

function getValue(form)
{
var getvalue = form1.field1.value
if(getvalue =='')
{
NOTEXT(form)
}
else
{
form.textarea1.value += ("" + getvalue + "")
}
}
</script>

<form name="form1">
<input type="hidden" name="field1" value="Test 123">
<textarea name="textarea1" rows="1" cols="45"></textarea>
<input type="button" value="Test" onClick="getValue(form);">
</form>

zachzach
09-12-2003, 09:21 PM
that should work

rogers
09-13-2003, 08:50 AM
I appreciate that. Thanks.

I wanted to copy the value from a column in an html table to a text field. How do you refer to the row and column in an html table and extract the value from it?

pcolafl
09-13-2003, 10:04 AM
Simply create a hidden text field for each table cell, duplicating that cells contents.

<script>
function NOTEXT(form)
{
form.value += ("")
}

function ClearStep(form) {
form1.done.value="";
return;
}


function getValue(form)
{
var donestep = form1.done.value
if(donestep =='')
{
alert ('You already did that.');
return false;
}
else
{
var getvalue = form1.field1.value;
var getvalue2 = form1.field2.value;
var getvalue3 = form1.field3.value;
if(getvalue =='')
{
NOTEXT(form)
}
else
{
form.textarea1.value += ("" + getvalue + "")
}
if(getvalue2 =='')
{
NOTEXT(form)
}
else
{
form.textarea1.value += ("" + getvalue2 + "")
}
if(getvalue3 =='')
{
NOTEXT(form)
}
else
{
form.textarea1.value += ("" + getvalue3 + "")
}
}
}
</script>

<form name="form1">
<input type="hidden" name="done" value="done">
<table name="table1" border="1">
<TR align="center">
<TD width="190" bgcolor="#FF0000"><b> Test 123
<input type="hidden" name="field1" value="Test 123, ">
</b></TD>
<TD width="67" rowspan="2" bgcolor="#FFFF00"><b>Test 456
<input type="hidden" name="field2" value="Test 456, ">
</b></TD>
</TR>
<TR align="center">
<TD width="190" bgcolor="#0099FF"><b><font>Test 789
<input type="hidden" name="field3" value="Test 789, ">
</font></b></TD>
</TR>
<TR bgcolor="#00FF00" align="center">
<TD colspan="2"> <b>
<textarea name="textarea1" rows="1" cols="45"></textarea>
</b></TD>
</TR>
<TR bgcolor="#009900" align="center">
<TD colspan="2"> <b>
<input type="button" value="Test" onClick="getValue(form);ClearStep(form);">
&lt; Try to push it twice</b></TD>
</TR>
</table>
</form>