Click to See Complete Forum and Search --> : Html Tables


clyde
04-24-2003, 02:22 PM
Help me if you can.

Please refer to the section of code below.

I have a HREF "Add" as the last cell in my table.
when i press the add button how can i have the value of the input field ( which is quanity ) sent with the other info in the table as listed down below.


any help will be appreciated

<tr>
<td><FONT size="-1"><a name="/%Mfgx%/">/%Mfg%/</a></FONT></td>
<td><FONT size="-1">/%Mfgdesc%/</FONT></td>
<td><FONT size="-1">/%Mfgnum%/</FONT></td>
<td><FONT size="-1">/%Mfgprice%/</FONT></td>
<td><FONT size="-1"><INPUT size="4" type="text" maxlength="4" name="Mfgqty"></FONT></td>
<td><FONT size="-1"><A href="/infcgilibp/isl550.pgm?mfgno=/%Mfgnum%/?TEST=/%Mfgdesc%/" target="_blank">Add</A></td>

</tr>

khalidali63
04-24-2003, 05:21 PM
I'd do it like this,add a function in js
e.g process();

<script type="text/javascript">
function process(obj){
//in thi sfunctiondo what you are doing in the link
obj.href = obj.href+"Mfgqty="+document.formName.Mfgqty.value
//the above line should append the input value to linksdestination
}

and in the link


<td><FONT size="-1"><A href="/infcgilibp/isl550.pgm?mfgno=/%Mfgnum%/?TEST=/%Mfgdesc%/" onclick="Process(this);" target="_blank">Add</A></td>

clyde
04-25-2003, 10:01 AM
KHALID

I Followed your instructions, but I am Still not quite there yet.

EveryTime ( In the Javascript function ) I refer to the input field in the table it comes back as undefined. I even Put in an alert in the function to see if it could be deiplayed, but it comes back as undefined.

As a test I put a input field outside of the table but still in
the form and it is recognized.

The code is below, maybe You can help me.

I am so close.

Thanks
Clyde







<HTML>

<HEAD>

<TITLE>Infocon Sales Page
</TITLE>

<META name="GENERATOR" content="IBM WebSphere Studio">
<SCRIPT language="JavaScript">

<!-- *** Process Quanity ***-->
function process(obj)
{

alert(document.Iform.Mfgqty.value);
obj.href = obj.href+"?mfgqt="+document.Iform.Mfgqty.value;
alert(obj.href);
}



<!-- *** NEW WINDOW ***-->
function open_new_viewc (form)
{

window.open("/infcgilibp/isl550.pgm?mfgno=XXX 878787TT",
"Reg_Wind", "scrollbars,status,top=10,left=70,height=500,width=760")
return;
}

<!-- *** NEW WINDOW ***-->
function open_new_viewx (form)
{

window.open("/infcgilibp/isl550.pgm?mfgno=XXX 878787TT",
"Reg_Wind", "scrollbars,status,top=10,left=70,height=500,width=760")

return;
}

//-->
</SCRIPT></HEAD>
<BODY>

<FORM name="Iform">

<TABLE align="right">
<TBODY>

<TR>
<TD align="right"><B>Date</B></TD>
<TD align="right"><B>4/25/2003</B></TD>
</TR>

<TR>
<TD align="right"><B>Time</B></TD>
<TD align="right"><B>10:27:36</B></TD>
</TR>
</TBODY>
</TABLE>


<BR>

<BR>

<TABLE cellspacing="0" cellpadding="2" border="10" bgcolor="#ffffff">
<TBODY>
<tr>
<td><U><B>Search Criteria</B></U></td>
<td>** No Search Entered **</td>
</tr>
</TBODY>
</TABLE>

<BR>

<TABLE cellspacing="0" cellpadding="2" border="10" bgcolor="#ffffff">
<TBODY>
<tr>
<td><FONT size="-1"><A href="#HWP">H-P PRODUCTS</A></td>
<td><FONT size="-1"><A href="#"></A></td>
<td><FONT size="-1"><A href="#"></A></td>
<td><FONT size="-1"><A href="#"></A></td>
<td><FONT size="-1"><A href="#"></A></td>
</tr>
</TBODY>
</TABLE>

<BR>
<A href="/infcgilib/isl999?mfgno=XXX 878787TT" target="_blank">View Cart</A>
<BR>
<BR>
<INPUT type="submit" name="OrdComp" value="ORDER COMPLETED">
<BR>
<BR>
<TABLE cellspacing="0" cellpadding="2" border="10" bgcolor="#ffffff">
<TBODY>
<tr>
<td><FONT size="-1"><U><B>Maunufacturer</B></U></FONT></td>
<td><FONT size="-1"><U><B>Description</B></U></FONT></td>
<td class="numeric"><FONT size="-1"><U><B>Part No.</B></U></FONT></td>
<td class="numeric"><FONT size="-1"><U><B>Price</B></U></FONT></td>
<td class="numeric"><FONT size="-1"><U><B>Quantity</B></U></FONT></td>
<td class="numeric"><FONT size="-1"><U><B>Add To Cart</B></U></FONT></td>
</tr>
<tr>
<td><FONT size="-1"><a name="HWP">H-P PRODUCTS</a></FONT></td>
<td><FONT size="-1">REPLACEMENT PACK</FONT></td>
<td><FONT size="-1">HWP HWKJ9989</FONT></td>
<td><FONT size="-1">$ 89.56</FONT></td>
<td><FONT size="-1"><INPUT size="4" type="text" maxlength="4" name="Mfgqty"></FONT></td>
<td><FONT size="-1"><A href="/infcgilibp/isl550.pgm?mfgno=HWP HWKJ9989?mfgdes=REPLACEMENT PACK" onclick="process(this);" target="_blank">Add</A></td>

</tr>
<tr>
<td><FONT size="-1"><a name="HWP">H-P PRODUCTS</a></FONT></td>
<td><FONT size="-1">2100 SERIES</FONT></td>
<td><FONT size="-1">HWP HW989UU</FONT></td>
<td><FONT size="-1">$ 89.56</FONT></td>
<td><FONT size="-1"><INPUT size="4" type="text" maxlength="4" name="Mfgqty"></FONT></td>
<td><FONT size="-1"><A href="/infcgilibp/isl550.pgm?mfgno=HWP HW989UU?mfgdes=2100 SERIES" onclick="process(this);" target="_blank">Add</A></td>

</tr>
<tr>
<td><FONT size="-1"><a name="HWP">H-P PRODUCTS</a></FONT></td>
<td><FONT size="-1">Toner Cartridge 500D</FONT></td>
<td><FONT size="-1">HWP 36663</FONT></td>
<td><FONT size="-1">$ 89.56</FONT></td>
<td><FONT size="-1"><INPUT size="4" type="text" maxlength="4" name="Mfgqty"></FONT></td>
<td><FONT size="-1"><A href="/infcgilibp/isl550.pgm?mfgno=HWP 36663?mfgdes=Toner Cartridge 500D" onclick="process(this);" target="_blank">Add</A></td>

</tr>
<tr>
<td><FONT size="-1"><a name="HWP">H-P PRODUCTS</a></FONT></td>
<td><FONT size="-1">Toner Carttridge 6500Y</FONT></td>
<td><FONT size="-1">HWP 6700-34</FONT></td>
<td><FONT size="-1">$ 89.56</FONT></td>
<td><FONT size="-1"><INPUT size="4" type="text" maxlength="4" name="Mfgqty"></FONT></td>
<td><FONT size="-1"><A href="/infcgilibp/isl550.pgm?mfgno=HWP 6700-34?mfgdes=Toner Carttridge 6500Y" onclick="process(this);" target="_blank">Add</A></td>

</tr>
</TBODY>
</TABLE>

</FORM>

</BODY>
</HTML>

khalidali63
04-25-2003, 10:13 AM
You are using same name for all input fields,that creates an array of input fields,in this case yuou have to point to array index that ou want to work on..for e.g
Mfgqty[number here].value

clyde
04-25-2003, 10:37 AM
I understand what you are saying.

If the table has 300 rows
how can I tell on which row the ADD was Clicked on.
In order to number the field as you have specified.

Please forgive me for asking these basic questions, I am new at this and learning.

Your Help is very appreciated.

khalidali63
04-25-2003, 11:59 AM
There are multiple ways you can find out which link was clicked..
1. name all the input fields in this manner

Mfgqty_1

Mfgqty_2 and so on..
and ammend your function call in the anchor tag as below

onclick="process(this,1);" and for the other link as

onclick="process(this,2);" where index will be incremented appropriately..in the javascript section

function process(obj,index){
//create the input object using index
var field = eval('document.Iform.Mfgqty_'+index);
//now you can use fields just as before

obj.href = obj.href+"?mfgqt_"+index+"="+field.value;
alert(obj.href);
}

2. second way will be using DOM find the parent of the element that triggers onclick event....etc

try to implement option 1.