PHP - Jquery - simple modal open data? - javascript

I have simply modal:
<div id="info" style="display: none;">
<h3 class="title">User info</h3>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="50%" align="right">ID user:</td>
<td>1</td>
</tr>
<tr>
<td width="50%" align="right">Login:</td>
<td>1</td>
</tr>
</table>
</div>
And php script:
$get = mysql_query("SELECT * FROM users");
while($user = mysql_fetch_assoc($get)) {
echo 'Wyświetl info o '.$user['login'].'';
}
JS - Open info click:
$('.open_info').click(function(e){
$('#info').modal({
autoResize: true
});
return false;
});
And i dont know how show info from user this user data.
Help :(

You are opening a hidden div in modal, you should use hidden wrapper div and open inner div in modal.
<div style="display: none;">
<div id="info">
<h3 class="title">User info</h3>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="50%" align="right">ID user:</td>
<td>1</td>
</tr>
<tr>
<td width="50%" align="right">Login:</td>
<td>1</td>
</tr>
</table>
</div>
</div>
Try using this method.

Try this..
$get = mysql_query("SELECT * FROM users");
while($user = mysql_fetch_assoc($get)) {
echo 'Wyświetl info o '.$user['login'].'';
echo '<div id="'.$user['id'].'" style="display: none;" >
<h3 class="title">User info</h3>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="50%" align="right">ID user:</td>
<td>1</td>
</tr>
<tr>
<td width="50%" align="right">Login:</td>
<td>1</td>
</tr>
</table>
</div>';
}
$(".open_info").click(function(){
var getid = $(this).attr("id");
var docnumbers = new Array();
$('.open_info').each(function() {
var selectdoc=this.id;
if(getid==selectdoc)
{
$("#"+selectdoc).show();
} else {
$("#"+selectdoc).hide();
}
});
});

Related

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

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;
}
}

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!!

Uncaught TypeError: Cannot read property 'outerHTML' of null

I try to get the content of table and put it in a new windows to print , but i alwys get this error:
the table is inside a modal , and it is return to modal dynamcly by ajax function :
this is the ajax function :
function view(id){
var html;
$.ajax({
url: "<?php echo site_url('admin/prescription/view_prescription_ajax') ?>/"+id,
type: 'POST',
dataType: 'html',
success:function(data){
html = data;
},
async: false
});
$('#view .modal-body').html(html);
$('#view').modal('show');
}
this is the htmt returned by this code
$data='';
$prescription = $this->prescription_model->get_prescription_by_id($id);
$template= $this->notification_model->get_template();
$data.='<table width="100%" border="0" id="printTable" class="pt" style="padding-bottom:0px; height:100%;" >
<thead>
<tr>
<td>
<table width="100%" style="border-bottom:1px solid;">
<tr>
<td style="line-height:110%">'.$template->header.'
</td>
</tr>
</table>
</td>
</tr>
</thead>
<tbody>
<tr>
<td >
<table width="100%">
<tr>
<td width="40%"><b>'.lang('name').'</b> : '.substr($prescription->patient,0,20).'</td>
<td width="18%"><b>'.lang('age').'</b> : '. date("Y")-$prescription->dob .' Years</td>
<td ><b>'.lang('sex').'</b> : '. $prescription->gender.'</td>
<td ><b>'.lang('id').'></b> :'.$prescription->prescription_id.'</td>
<td ><b>'.lang('date').'</b> : '. date("d-m-y", strtotime($prescription->date_time)).'</td>
</tr>
</table>
</td>
</tr>
<tr height="100%">
<td valign="top">
<table width="100%" border="0">
<tr>
<td width="51%" valign="top">
<table width="80%" border="0">
<tr>
<td width="100%">
<table border="0" >
<tr>
<td><b>Medical History</b></td>
</tr>';
$c = json_decode($prescription->case_history_id);
if(is_array($c)){
foreach($c as $new){
$data.='<tr><td>'.$dis = $new .'</td></tr>';
}
}else{
$data.='<tr><td>'.$c.'</td></tr>';
}
$data.='<tr>
<td>'. $prescription->case_history.'</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0">
<tr>
<td><b>Frequency</b></td>
</tr>
<tr>
<td>'.$prescription->frequency.'</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="51%">';
$d = json_decode($prescription->tests);
//echo '<pre>'; print_r($d);'</pre>';
if(!empty($d[0])){
$data.='<table border="0" width="100%">
<tr>
<td><b>'.lang('test').'</b></td>
</tr>';
$ins = json_decode($prescription->test_instructions);
if(is_array($d)){
$i=1;
foreach($d as $key => $new){
$data.='<tr><td>'.$i.'. '.$d[$key] .'<td></tr>';
if(!empty($ins[$key])){
$data.='<tr><td><p style="padding-left:14px;"><small>('.$ins[$key] .')</small></p><td></tr>';
}
$i++;}
}else{
$data.='<tr><td>'.$i.' '.$d.'<td></tr>';
$data.='<tr><td><p style="padding-left:14px;"><small>( '.$ins.' )</small></p><td></tr>';
}
$data.='</table>';
}
$data.='</td>
</tr>
</table>
</td>
<td valign="top">
<table border="0" width="100%" >
<tr>
<td><p><span style="font-size:26px"><b>R</span ><sub style="font-size:18px">x</b></sub></p></td>
</tr>';
$d = json_decode($prescription->medicines);
$ins = json_decode($prescription->medicine_instruction);
if(is_array($d)){
$i=1;
foreach($d as $key => $new){
if(!empty($d[$key]))
$data.='<tr><td style="padding-left:18px;">'.$i.'. '.$d[$key] .'<td></tr>';
$data.='<tr><td><p style="padding-left:32px;"><small>'.#$ins[$key] .'</small></p><td></tr>';
$i++;}
}else{
$data.='<tr><td style="padding-left:18px;">'.$i.' '.$d.'<td></tr>';
$data.='<tr><td><p style="padding-left:32px;"><small>'.$ins.'</small></p><td></tr>';
}
$data.='<tr>
<td>';
if(!empty($prescription->remark)){
$data.='<table width="100%" border="0">
<tr>
<td><b>'.lang('remark').'</b></td>
</tr>
<tr>
<td>'.$prescription->remark.'</td>
</tr>
</table>';
}
$data.='</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td style="border-top:1px solid;" class="aligncenter">
'.$template->footer.'
</td>
</tr>
</tfoot>
</table>
<div class="form-group no-print">
<div class="row no-print">
<div class="col-sm-4 pull-right">
<a class="btn btn-default yes-print no-print" id="print_p" onClick="printData();" style="margin-right: 5px;"><i class="fa fa-print"></i>'.lang('print').'</a>
<i class="fa fa-download"></i>'.lang('generate_pdf').'
</div>
</div>
</div>
';
echo $data;
this is javascript
function printData()
{
var divToPrint=document.getElementById("printTable");
newWin= window.open("");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();
}
you should call print data on success because events are not binding after dom content added to dom later.
also don't forget to remove onClick="printData" from button attribute
function view(id){
var html;
$.ajax({
url: "<?php echo site_url('admin/prescription/view_prescription_ajax') ?>/"+id,
type: 'POST',
dataType: 'html',
success:function(data){
html = data;
$("#print_p").on("click", function(e){ printData(); });
},
async: false
});
$('#view .modal-body').html(html);
$('#view').modal('show');
}

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"
);

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!

Categories

Resources