show submit <a href> link onchange and pass the value of the input box changed

sergo

New Member
I am not a JavaScript person really, I write in ASP and use a SQL database in the backend. But our marketing director requested a change that will use JavaScript.On our view cart page, we're currently displaying an input box with a modify button to allow customers to change the quantity of the listed item (in that row... there could be multiple products in their cart, each having their own quantity input). \[code\]<form method="post" action="updateitem.asp"><input type="hidden" name="product_id" value="http://stackoverflow.com/questions/14408968/<%= PRODUCT_ID %>">Quantity: <input type"text" name="quantity"><input type="image" name="Submit" src="http://stackoverflow.com/graphics/modify.gif" align="middle" border="0" alt="Continue"></form>\[/code\]What I'd like to make work is something like this. Hrm, assuming I need to do my form/div name differently for each product? I can easily write the product_id into the id tags but then assuming I'd also need to loop through my function for each one. I've gotten this far in writing the replacement code:Get Dataset from Database (items in cart) and loop through:\[code\]<form method="post" action="updateitem.asp" id="updateitems<%= PRODUCT_ID %>">Quantity: <input type="text" name="qty<%= PRODUCT_ID %>" OnChange="Javascript:UpdateQty()")<div id="showlink<%= PRODUCT_ID %>"><br /><a href="http://stackoverflow.com/questions/14408968/updateitem.asp?product_id=<%= PRODUCT_ID %>&quantity=NEWQUANT"><span class="BodyTiny">update</span></a></div></form>\[/code\]END LOOPSo if the quantity changes, it displays the word "update" where they can click and it passes whatever quantity that is in the quantity field to the updateitem.asp (in a way I can then update it in the database in ASP/SQL). In the code above, if we could just insert the new # in the a href statement after quantity=, then I could fix it in the updateitems.asp page without a problem.I'm not sure where to even begin honestly, I have this so far:LOOP through dataset so each product has its own function\[code\]<script Language="JavaScript"><!--function UpdateQty(updateitems<%= PRODUCT_ID %>) {Show div updateitems<%= PRODUCT_ID %>Replace NEWQUANT within that div with the value in the input field qty<%= PRODUCT_ID %>}//--></script> \[/code\]END LOOPI'm having a few problems... [*]I am not sure how to write the function UpdateQty. It should A) display the stuff in div id=showlink, and B) add the # from the input named quantity quantity to the href so I can update it in the database on the next page[*]If they have JavaScript turned off, they should be able to enter a new quantity and just hit enter for it to submit the form. I believe this will work as its a form with 1 text input and 1 hidden one, so just hitting enter in the text input should submit it. But that should still work with whatever JavaScript is added to make the showlink div show if it changes.[*]Do I need to add a class to my CSS for showlink? If so, what do I need to put in it?Any help would be greatly appreciated!Mahalo!
 
Back
Top