...

View Full Version : Getting Info from a Form to a table... NEED HELP!



brodjah
05-18-2009, 03:41 PM
I am a newbe to web delevlopment.
I have the following form:
<form name="quantityconnect" method="get" action="http://www.doc.ic.ac.uk/~gu1/cgi-bin/formnew1.cgi ">

Quantity:
<select name="Quantity" size="1">
<option value="1">...1...</option>
<option value="2">...2...</option>
<option value="3">...3...</option>
<option value="4">...4...</option>
<option value="5">...5...</option>
<option value="6">...6...</option>
</select>

<input type="submit" value="Add to my basket">

</form>

What I want is for when the "Add to my basket" button is clicked, is for the value selected from the drop down box to be inputted into this table:

<table id="shoppingcart border="1">
<tr bgcolor="#ff0000">
<th align="center"><b>Item</b></th>
<th align="center"><b>Quantity</b></th>
<th align="center"><b>Price</b></th>
<th align="center"><b>Sum</b></th>
</tr>
<tr cellpadding="5">
<td><p><img src="20questionsbasket.jpg" alt="20questions" title="20 Questions">20 Questions Electronic Mind Reader</p></td>
<td>QUANTITY INSERTED HERE</td>
<td>9.77</td>
<td></td>
</tr>
<tr>
</table>

I have experimented many different ways unsuccessfully, and am now assuming i need to use some sort of javascript... Any1 have any code to help?

Thanks
Mike

abduraooft
05-18-2009, 03:51 PM
What I want is for when the "Add to my basket" button is clicked, is for the value selected from the drop down box to be inputted into this table: Don't you need to save the selected data in your DB/session Or just need to add that string to your table cell from the client side?

brodjah
05-18-2009, 04:17 PM
Don't you need to save the selected data in your DB/session Or just need to add that string to your table cell from the client side?

Just adding the string client side that section of the table...
Also if possible, for that section of the table to display '...0...'(zero) by default.

abduraooft
05-18-2009, 04:39 PM
<select name="Quantity" size="1" id="Quantity">
<option value="1">...1...</option>
<option value="2">...2...</option>
<option value="3">...3...</option>
<option value="4">...4...</option>
<option value="5">...5...</option>
<option value="6">...6...</option>
</select>

<td id="targetcell">QUANTITY INSERTED HERE</td>
You may call the following function in the onclick of your button,

function add(){ document.getElementById('targetcell').innerHTML='...'+document.getElementById('Quantity').value+'... ';
}

Also if possible, for that section of the table to display '...0...'(zero) by default. Can't you just write it there?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum