The value of variable is not showing while sending email using phpmailer - javascript

link for image i have written a code which sends invoice details via email after completing the order. but the issue is that when i am running this code in a file.php it is working fine and giving me all the value of variable and executing the while loop
But while mailing, the while() function is not getting execueted and the invoice details are appearing null in the email.
The mail consist of details of the shopping which the user had done.
function sentInvoice($conn,$oid)
{
$url="http://localhost/user/contactus.php";
$date=date('Y');
$nego=0;
$res=mysqli_query($conn,"select order_details.*,product.id,product.pname,orders.total_price from order_details inner join product on product.id=order_details.product_id inner join orders on orders.id=order_details.order_id where order_details.order_id='$oid'");
$row=mysqli_fetch_assoc(mysqli_query($conn,"select orders.*, ecom_users.id,ecom_users.fname,ecom_users.email from orders inner join ecom_users on ecom_users.id=orders.uid where orders.id='$oid'"));
$total=0;
$dateArr=explode(" ",$row['added_on']);
$order_date=$dateArr[0];
$html='<body>
<span class="preheader">This is an invoice for your purchase on '.$order_date.'.</span>
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
<table class="email-content" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<!-- Email Body -->
<tr>
<td class="email-body" width="100%" cellpadding="0" cellspacing="0">
<table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0" role="presentation">
<!-- Body content -->
<tr>
<td class="content-cell">
<div class="f-fallback">
<h1>Hi '.$row['fname'].',</h1>
<p>Thanks for using Our Website ShopHana. This is an invoice for your recent purchase.</p>
<table class="attributes" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td class="attributes_content">
<table width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td class="attributes_item">
<span class="f-fallback">
<strong>Amount:'.$row['total_price'].'</strong>
</span>
</td>
</tr>
<tr>
<td class="attributes_item">
</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- Action -->
<table class="purchase" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<h3>'.$oid.'</h3>
</td>
<td>
<h3 class="align-right">'.$order_date.'</h3>
</td>
</tr>
<tr>
<td colspan="2">
<table class="purchase_content" width="100%" cellpadding="0" cellspacing="0">
<tr>
<th class="purchase_heading" align="left">
<p class="f-fallback">Description</p>
</th>
<th class="purchase_heading" align="right">
<p class="f-fallback">Amount</p>
</th>
</tr>';
while($rem=mysqli_fetch_assoc($res))
{
$pid=$rem['product_id'];
$user_id=$row['uid'];
$a_query=mysqli_fetch_assoc(mysqli_query($conn,"select negotiate from addtocart where pid=$pid and uid=$user_id"));
$nego=$a_query['negotiate'];
echo $nego;
if($nego!=0)
{
$total=$total+$nego;
}
else
{
$total=$total+$rem['price'];
}
//this part is not showing up in the email
$html.='
<tr>
<td width="80%" class="purchase_item"><span class="f-fallback">'.$rem['pname'].'</span></td>
<td class="align-right" width="20%" class="purchase_item"><span class="f-fallback">'.$rem['price'].'</span></td>
</tr>';
}
$html.='<tr>
<td width="80%" class="purchase_footer" valign="middle">
<p class="f-fallback purchase_total purchase_total--label">Total</p>
</td>
<td width="20%" class="purchase_footer" valign="middle">
<p class="f-fallback purchase_total">'.$total.'</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>If you have any questions about this invoice, simply reply to this email or reach out to our support team for help.</p>
<p>Cheers,
<br>The ShopHana Team</p>
<!-- Sub copy -->
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td class="content-cell" align="center">
<p class="f-fallback sub align-center">©'.$date.' ShopHana All rights reserved.</p>
<p class="f-fallback sub align-center">
[SHOPHANA, LLC]
<br>1234 Street Rd.
<br>Suite 1234
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>';
include('smtp/PHPMailerAutoload.php');
$mail=new PHPMailer(true);
$mail->isSMTP();
$mail->Host="smtp.gmail.com";
$mail->Port=587;
$mail->SMTPSecure="tls";
$mail->SMTPAuth=true;
$mail->Username="somemail9245#gmail.com";
$mail->Password="passwords";
$mail->SetFrom("shophana2337#gmail.com");
$mail->addAddress($row['email']);
$mail->IsHTML(true);
$mail->Subject="Invoice Details";
$mail->Body=$html;
$mail->SMTPOptions=array('ssl'=>array(
'verify_peer'=>false,
'verify_peer_name'=>false,
'allow_self_signed'=>false
));
if($mail->send()){
return true;
}else{
return false;
}
}

Related

Remove spaces between two inner ```<td>``` elements

var str1 = "78896541230";
str1 = str1.replace(/.(?=.{4})/g, 'x');
document.getElementById('output').innerHTML = str1;
<table cellspacing="0" cellpadding="0" border="0" id="maintable" class="maintable">
<tr>
<td valign="top">
<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center" id="PageHeadingTable">
<tr>
<td id="PageHeading" nowrap="true">OTP Verification</td>
<td id="PageHeadingDate">
<xsl:value-of select="//faml/request/datetime" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="100%" valign="top">
<div class="y_scroll" id="contentarea" style="width:98%;position:absolute">
<!--y_scroll start-->
<div class="contentarea">
<!--contentarea start-->
<span id="box" class="box"> <!--rounded curve/border start-->
<div class="toppanel"><ul><li></li></ul></div>
<div class="middlepanel">
<table border="0" cellspacing="0" cellpadding="1" class="formtable">
<caption>Confirm your identity</caption>
<tr> <td>A One Time Password(OTP) has been sent to your mobile phone with number ending in </td><td id="output"></td>
</tr>
<tr ><td > If this is not your mobile number, you are advised to end your internet banking and call us</td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
</div>
</table>
</div>
<div class="bottompanel"><ul><li></li></ul></div>
</span>
</div>
<!--contentarea end-->
</div>
</td>
</tr>
</table>
I am trying to make an OTP page where user can input the recieved OTP on the screen.Since I have masked the user's phone number for security reasons. I am getting the value of masked phone number in seperate <td>. The only problem is there is a space between my two <td>. I am not sure how to remove the space since its nested. I have added the code in the snippet for better understanding of my problem.
Any help or suggestion will be appreciated.Thanks!!

jQuery Search multiple Tables for text and click a button if text is found

I'm trying to search some tables and click a button inside a cell of a specific table. This is my current code
links[1].click();
iimPlayCode('WAIT SECONDS = 2')
var compTabs = window.content.document.getElementById('compTabs')
var compTabList = compTabs.getElementsByClassName("tabNavigation top_tabs")
if (compTabList[0].children[0].innerText.match(/voting/gi)) {
$('#candidatesList').each(function () {
if ($(this).text().match(/john/gi)) { // search for text
// everything works fine until here, don't know how to click the specific button
//get id of button and click it
}
})
}
This is the result of $(this).text():
John
100%
05/09/2013
Vote
And this would be the result of $(this).html()
<tr style="text-align: center;">
<td><img src="http://somewebsite.com" width="36px"></td>
<td>John</td>
<td>100%</td>
<td>05/09/2013</td>
<td class="last-child"><button rel="123" id="6332" class="button_85 sa_vote">Vote</button></td>
</tr>
What I have to do is to click the button with that specific ID in this case '6332'.
This is a bit more complete html code.
<div id="compTabs">
<div class="tabs">
<ul class="tabNavigation top_tabs">
<li rel="#tab_voting" class="selected">
<table cellspacing="0" cellpadding="0">
<tbody><tr>
<td width="28px"><img src="http://somewebsite.com/design/img/new_style/tabs/voting.png"></td>
<td>Voting</td>
</tr>
</tbody></table>
</li>
<li rel="#tab_shareholders">
<table cellspacing="0" cellpadding="0">
<tbody><tr>
<td width="28px"><img src="http://somewebsite.com/design/img/new_style/tabs/shareholders.png"></td>
<td>Shareholders</td>
</tr>
</tbody></table>
</li>
</ul>
<div class="compTabsContent" id="tab_voting" style="display: block;">
<div style="height:390px;margin:0;" class="companyBody">
<table cellspacing="0" cellpadding="0" width="100%" style="margin-top: 10px;" class="proTable">
<tbody><tr valign="top">
<td style="text-align:center;height:35px;vertical-align:middle;font-size:14px;">
Vote to elect <b style="color:red"> General Director </b>. <div id="startTimer" class="timerStyle01">1d 22h:13m:30s</div>
</td>
</tr>
</tbody></table>
<table cellspacing="0" cellpadding="0" width="100%" style="margin-top:10px">
<tbody><tr valign="top"><td width="35%">
<table cellspacing="0" cellpadding="0" class="proTable newTable">
<thead>
<tr><th class="thb" colspan="3">All shareholders</th></tr>
<tr>
<th width="36px"> </th>
<th>Shareholder name</th>
<th>He voted</th>
</tr></thead>
<tbody id="listOfAdministrators">
<tr style="text-align: center;">
<td><img width="36px" src="http://somewebsite.com/content/user/small/user_1364379268_234.jpg"></td>
<td>John</td>
<td><img src="http://somewebsite.com/design/img/new_style/tabs/no.png"></td>
</tr>
</tbody>
</table>
</td>
<td width="10px"></td>
<td>
<table cellspacing="0" cellpadding="0" class="proTable newTable">
<thead>
<tr><th class="thb" colspan="5">Vote to elect <b style="color:red"> General Director </b>.</th></tr>
<tr>
<th width="36px"> </th>
<th>Shareholder name</th>
<th>Shares</th>
<th>Date of shares purchase</th>
<th> </th></tr>
</thead>
<tbody id="candidatesList">
<tr style="text-align: center;">
<td><img width="36px" src="http://somewebsite.com/content/user/small/user_1364379268_234.jpg"></td>
<td>John</td>
<td>100%</td>
<td>05/09/2013</td>
<td class="last-child"><button class="button_85 sa_vote" id="60928" rel="234">Vote</button></td>
</tr>
</tbody>
</table>
</td></tr>
</tbody></table>
</div></div>
<div class="compTabsContent" id="tab_shareholders" style="display: none;"><div style="height:390px;margin:0;" class="companyBody">
<table cellspacing="0" cellpadding="0" style="margin-top:15px;font-size: 11px;" class="proTable newTable">
<thead>
<tr><th style="font-size:13px;" class="thb" colspan="4">All shareholders</th></tr>
<tr>
<th width="36px" style="border-left: 1px solid #d2d2d2;"> </th>
<th>Shareholder name</th>
<th>Shares</th>
<th>Date of shares purchase</th>
</tr>
</thead>
<tbody>
<tr style="text-align: center;">
<td><img width="36px" src="http://somewebsite.com/content/user/small/user_1364379268_234.jpg"></td>
<td>John</td>
<td>100%</td>
<td class="last-child">05/09/2013</td>
</tr>
</tbody>
</table>
</div></div>
</div>
</div>
You may try a solution without jQuery, something like this:
links[1].click();
iimPlayCode(
"WAIT SECONDS=2" + "\n" +
"TAG POS=1 TYPE=TBODY ATTR=ID:candidatesList" + "\n" +
"TAG POS=R-1 TYPE=* ATTR=*" + "\n" +
"TAG POS=R1 TYPE=TD ATTR=TXT:*john*" + "\n" +
"TAG POS=R1 TYPE=BUTTON ATTR=TXT:Vote" + "\n"
);

Send email that includes tables from the webpage into the body of the email

I was wondering if I can pass the tables on the webpage to the body of the email. I was wondering if this was possible and if so point me in the right direction
My Button:
<input type="submit" value="SUBMIT EMAIL TO: GNOC" <a
href="mailto:myemail#whatever.com">
Table:
<table cellpadding="4" cellspacing="0"
border="0" width="100%">
<tr>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
colspan="3" valign="top" width="100%">
<WebPartPages:WebPartZone runat="server"
Title="loc:Header" ID="Header"
FrameType="TitleBarOnly"/> </td>
</tr>
<tr>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
rowspan="4" valign="top" height="100%">
<WebPartPages:WebPartZone runat="server"
Title="loc:LeftColumn" ID="LeftColumn"
FrameType="TitleBarOnly"/> </td>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
valign="top" height="100%"> <WebPartPages:WebPartZone
runat="server" Title="loc:Row1" ID="Row1"
FrameType="TitleBarOnly" Orientation="Horizontal"/>
</td>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
rowspan="4" valign="top" height="100%">
<WebPartPages:WebPartZone runat="server"
Title="loc:RightColumn" ID="RightColumn"
FrameType="TitleBarOnly"/> </td>
</tr>
<tr>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
valign="top" height="100%"> <WebPartPages:WebPartZone
runat="server" Title="loc:Row2" ID="Row2"
FrameType="TitleBarOnly" Orientation="Horizontal"/>
</td>
</tr>
<tr>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
valign="top" height="100%"> <WebPartPages:WebPartZone
runat="server" Title="loc:Row3" ID="Row3"
FrameType="TitleBarOnly" Orientation="Horizontal"/>
</td>
</tr>
<tr>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
valign="top" height="100%"> <WebPartPages:WebPartZone
runat="server" Title="loc:Row4" ID="Row4"
FrameType="TitleBarOnly" Orientation="Horizontal"/>
</td>
</tr>
<tr>
<td
id="_invisibleIfEmpty" name="_invisibleIfEmpty"
colspan="3" valign="top" width="100%">
<WebPartPages:WebPartZone runat="server"
Title="loc:Footer" ID="Footer"
FrameType="TitleBarOnly"/> </td>
</tr>
<script
language="javascript">if(typeof
(MSOLayout_MakeInvisibleIfEmpty) == "function")
{MSOLayout_MakeInvisibleIfEmpty();}</script>
</table>
Goal: Import table from webform into email body
It isn't possible.
However, why don't you use an ajax call to send all the information in a table as if it were a form? On the separate php document you call to, use PHP's mail functionality (http://php.net/manual/en/function.mail.php)
for example:
<form type="POST">
<table> <!-- This is your table -->
<tr>
<td>
Username
</td>
<td>
<input type="text" name="username" value="whateveruserentered" />
</td>
</tr>
<table>
So in the ajax method, you'd send username through. Then in the php page you called you'd say
<table>
<tr>
<td>
Username
</td>
<td>
<?php echo $_POST['username']; ?>
</td>
</tr>
<table>
So you're recreating the table.
Put all of that in the body of the mail property, and off it goes. Fully fledged table just like on the original page.
In order to send the templated information you want to?

Search Results page destroys background

Here is the original site. usahvacsupply.com Once you search an item, the search results take over the whole page and kill the background. I'm not sure how to control the overflow. The part of the site where the overflow goes haywire is http://www.usahvacsupply.com/servlet/Categories. I'll post more code if needed. The code on the bottom corresponds with the http://www.usahvacsupply.com/servlet/Categories page. any help would be appreciated.
<table id="body" width="960" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="100%">
<script type="text/javascript">
if (!createBookmark) {
var createBookmark = function() {
if (window.sidebar) // Mozilla Firefox Bookmark
window.sidebar.addPanel(document.title, location.href, '');
else if (window.external) // IE Favorite
window.external.AddFavorite(location.href, document.title);
else // all others
alert("Please press CTRL+D to bookmark this page.");
};
}
</script>
<table id="layout" class="panel-layout" width="100%" cellspacing="0" cellpadding="0" border="0" rules="none">
<tbody>
<tr>
<td id="p1" valign="top">
<script type="text/javascript">
var ProStores;
if (!ProStores)
ProStores = {};
ProStores.PageLink = function(link) {
var strParams = 's=' + link.getAttribute('page');
var strThis = location.href;
if (strThis.indexOf('?') > -1) {
if (strThis.search(/s=[0-9]+/) > -1)
link.href = strThis.replace(/s=[0-9]+/, strParams);
else
link.href = strThis + '&' + strParams;
}
else
link.href = strThis + '?' + strParams;
};
</script>
<link href="/servlet/0-3-30d-727500-com.prostores.panel.List%7Estyle.css/Asset" title="style" type="text/css" rel="stylesheet">
<style type="text/css">
<table id="cataloglist.31" class="list-boundary" width="100%" cellspacing="0" cellpadding="0" border="0" rules="none">
<tbody>
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" rules="none">
<tbody>
<tr>
<td valign="top" align="left" colspan="1">
<h1 align="left">Search Results</h1>
<div class="" align="left" style="padding:2px">
<p>
Found
<b>1000</b>
product(s) for
<b>All</b>
(1-25 of 1000)
</p>
</div>
</td>
</tr>
<tr>
<td valign="middle" colspan="1">
<div class="product-list-container">
<div class="top">
<div class="right">
<div class="left"></div>
</div>
</div>
<div class="titlebar group-title">
<b> Breakers | Bryant Carrier Payne Day&Night </b>
</div>
<div class="panel-content">
<center>
<table class="" width="100%" cellspacing="2" cellpadding="0" border="0">
<tbody>
<tr>
<td colspan="1" style="height:1px"></td>
</tr>
<tr>
<td class="item-cell" width="100%" valign="bottom" height="100%" style="padding:8px">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" rules="none">
</td>
</tr>
<tr>
</tbody>
</table>
</center>
</div>
<div class="bottom">
</div>
</td>
</tr>
<tr>
<tr>
<tr>
<tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
I can see that your problem isn't occuring anymore, but when you search for a product that doesn't exist. Your div.footerBorder gets floated over the background to the left. Fix that by applying:
margin-left: 10px;
To your
/servlet/0-0-30d-13e0e1158d0-legacycss/Asset
Inside your ".footerBorder" on row 240, replace the whole rule to:
.footerBorder {
width: 960px;
min-height: 160px;
background: url("/images/store_version1/footer.gif") no-repeat;
margin-left: 10px;
}
Edit:
If that conflicts on other pages, let me know and I'll help you with it. Cheers!

How to calculate values dynamically from textbox using jQuery?

I have an invoice.jsp page where I have to calculate some value in the textbox using jQuery or with any other way.
I don't know much about jQuery. Please help me to solve this problem.
In my invoice there is a quantity textbox. If the user enters the quantity then the calculated price should be calculated dynamically i.e (total_subPrice= unit_price * quantity) and shown in another textbox called "price".
And again the total sum of all the prices should appear in the button as a Total.
Please note: all the row values are coming from my database table based on the selection of items by users.
I have used only this code to show values in my invoice.jsp page:
<s:iterator value="#session.BOK" status="userStatus">
<tr style="height: 10px;">
<td width="65%" align="left"><s:property value="bookTitile"/></td>
<td width="10%" align="left"><s:property value="price"/></td>
<td width="10%" align="center"><s:textfield name="quantity" value="%{quantity}" size="2" /></td>
<td width="15%" align="center" >
<s:textfield value="%{price}" name="" size="6"></s:textfield>
</td>
</tr>
</s:iterator>
And my invoice.jsp output looks like this:
I have no idea how to calculate the line Total based on the quantity chosen and also display the sum of all the line total in the grand total textbox (see below invoice image).
I also tried this but I am still unable to solve my problem.
My full JSP code:
<table width="100%" height="50%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="74%">
<s:form action="dfs" id="form3" theme="simple">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="your_content">
<tr>
<td valign="top" height="10%">
<div id="invNum">Invoice# 12688</div>
<div id="ttielMain">Vision Books</div>
<div id="Orgaddress"> Thamel Kathmandu Nepal</div>
<div id="phoneNum"> Tel# 00977-1-12173803</div>
<div id="websiteOrg"> www.thebestbookfinder.com</div>
</td>
</tr>
<tr>
<td valign="top" width="100%" align="left">
----------------------------------------------------------- -----------------------------------
</td>
</tr>
<tr>
<td height="6%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;font-family: serif;font-weight: bold;font-size: 14px;">
<td width="65%" align="left">Title</td>
<td width="10%" align="left">Unit Price</td>
<td width="10%" align="center">Qty</td>
<td width="15%" align="left">Line Total</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="65%" align="left">
-------------------------------------------------------
</td>
<td width="10%" align="left">----------</td>
<td width="10%" align="center">-----</td>
<td width="15%" align="left">-------------</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="65%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<s:iterator value="#session.BOK" status="userStatus">
<tr style="height: 10px;">
<td width="65%" align="left"><s:property value="bookTitile"/></td>
<td width="10%" align="left"><s:property value="price"/></td>
<td width="10%" align="center"><s:textfield name="quantity" value="%{quantity}" size="2" /></td>
<td width="15%" align="center"><s:textfield value="%{price}" name="" size="6"></s:textfield></td>
</tr>
</s:iterator>
</table>
</td>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="100%" align="right" colspan="5">
------------------------------------
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="100%" align="right" colspan="5" style="font-weight: b">
<s:set var="total" value="%{0}" />
<s:iterator value="#session.BOK">
<s:set var="total" value="%{price + #attr.total}" />
</s:iterator>
<s:textfield name="subtotal" value="%{'' + #attr.total}" size="5"> </s:textfield>
</td>
</tr>
</table>
</td>
</tr>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="100%" align="right" colspan="5">Discount:<sj:textfield name="amt" size="1" placeholder=" %"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="100%" align="right" colspan="5">
--------------------------------------------------------------------------------------------------
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="100%" align="right" colspan="5" style="font-weight: bolder;">
<s:set var="total" value="%{0}" />
<s:iterator value="#session.BOK">
<s:set var="total" value="%{price + #attr.total}" />
</s:iterator>
Total: <s:property value="%{'' + #attr.total}" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1%" valign="top" width="100%">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height: 10px;">
<td width="100%" align="right" colspan="5">
--------------------------------------------------------------------------------------------------
</td>
</tr>
</table>
</td>
</tr>
As #flow said, use .change():
$(function() {
$('input[name^="quantity"]').change(function() {
var unitprice = $(this).siblings('input[name^="unitprice"]').val();
$(this).siblings('input[name^="price"]')
.val($(this).val() * unitprice);
});
});
Use .change() on your inputs.
jQuery Docs - Change

Categories

Resources