PHP - Need Some Help Of Onclick Button In Php
i have this code which fetch meta tags and title
function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); curl_close($ch); return $data; } $html = file_get_contents_curl("http://example.com/"); //parsing begins he $doc = new DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); //get and display what you need: $title = $nodes->item(0)->nodeValue; $metas = $doc->getElementsByTagName('meta'); for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if($meta->getAttribute('name') == 'description') $description = $meta->getAttribute('content'); if($meta->getAttribute('name') == 'keywords') $keywords = $meta->getAttribute('content'); } if(!title == ' ') { echo ' found a title'; }in this code you see in last i have if condition (!title==' ') its execute it when i open file i want its only run when i click the html button like <input type="button" name="Release" onclick="" value="Click "> please tell me what i do help me Similar TutorialsHello, What I am looking to do is have a series of buttons laid out and when the user 'onClick', a table from my MySQL database will load into a scrollable textbox within the same webpage. I figure I need to go about this using AJAX, which unfortunately I have basically no experience in. For example purposes here is what I have going: This php code basically just displays the table we want to tie the button click to. Code: [Select] <?php include("connect.php"); //Query of facebook database $facebook = mysql_query("SELECT * FROM facebook") or die(mysql_error()); //Output results if(!$facebook) { echo "There was an error running the query: " . mysql_error(); } elseif(!mysql_num_rows($facebook)) { echo "No results returned"; } else { $header = false; echo "<table border='1'>\n"; while($row = mysql_fetch_assoc($facebook)) { if(!$header) { echo "<tr>\n"; foreach($row as $header => $value) { echo "<th>{$header}</th>\n"; } echo "</tr>\n"; } echo "<tr>\n"; foreach($row as $value) { echo "<th>{$value}</th>\n"; } echo "</tr>\n"; } echo "</table>\n"; } mysql_close(); ?> I'd really like to make this as easy as possible. After doing research, I figured that just Javascript would not be enough because it is client-side. It would be great if someone could point me in the right direction. Thanks in advance to anyone who replies. I have a dynamic script and need to create a click event function with JavaScript to delete the row which has a checkbox checked when the delete button is pressed. This is being implemented with PHP and as now serves as light code for this matter at hand. I was only able to delete all rows. I have my efforts with the js functions too. <script type="text/javascript"> var counter = 1; var limit = 6; function addTextArea() { if (counter == limit-1) { alert("Maximum limit " + counter + " sorry"); return false; } else { <!-- CAUTION THIS IS BACKWARDS. --> var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><textarea name='fav_det[]' id=counter rows='3' cols='20'>"; document.getElementById('div6').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><textarea name='fav_col' id=counter rows='3' cols='20'>"; document.getElementById('div5').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><textarea name='fav_mod[]' id=counter rows='3' cols='20'>"; document.getElementById('div4').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = " " + (counter + 1) + " <br><input type='text' name='truck[]' id=counter>"; document.getElementById('div3').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = " " + (counter + 1) + " <br><input type='text' name='car[]' id=counter>"; document.getElementById('div2').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><input type='checkbox' name='chk[]' id=counter>"; document.getElementById('div1').appendChild(newdiv); counter++ return true; } } </script> <script type="text/javascript"> function deleteRowS(dataTable) { for (var rowi= table.rows.length; rowi-->0;) { var row= table.rows[rowi]; var inputs= row.getElementsByTagName('dataTable'); for (var inputi= inputs.length; inputi-->0;) { var input= inputs[inputi]; if (input.type==='checkbox' && input.checked) { row.parentNode.removeChild(row); break; } } } } </script> <script type="text/javascript"> function deleteRow() { var table = document.getElementById(tableID).tBodies[0]; var rowCount = table.rows.length; // var i=1 to start after header for(var i=1; i<rowCount; i++) { var row = table.rows[i]; // index of td contain checkbox is 8 var chkbox = row.cells[6].getElementsByTagName('input')[0]; if('checkbox' == chkbox.type && true == chkbox.checked) { table.deleteRow(i); } } }</script> </head> <table> <tr><td valign='top'><b>NEED DELETE ROW WITH CHECKBOX FUNCTION:</td></tr> </table> <table id="dataTable" width="auto" style="margin:-4px 0 0 0; padding:14px 0 0 0;" cellspacing="10px"><tbody id="dataTable"></tbody> <tr> <td valign='Top'> ✗ <div id="div1"> <input type="checkbox" name="chk[]" autocomplete="off" id="1" > </div> </td> <td valign='Top'> cars <div id="div2"> <input type="text" name="car[]" id="2" > </div> </td> <td valign='Top'> trucks <div id="div3"> <input type="text" name="truck[]" id="3" > </div> </td> <td valign='Top'> your favorite model <div id="div4"> <textarea name="mod[]" id="4" rows="3" cols="20"></textarea> </div> <br><br> </td> <td valign='Top'> your favorite add-ons <div id="div5"> <textarea name="fav_col" id="5" rows="3" cols="20"></textarea> </div> </td> <td valign='Top'> explain vehicle overall <div id="div6"> <textarea name="fav_det" id="6" rows="3" cols="20"></textarea> </div> </td> </tr> </table> <input type="button" value="Add another" onClick="addTextArea();" /> <input type="button" value="Delete row" onclick="deleteRow('dataTable');deleteRowS('dataTable')" /> Which languages do I need to make this happen? And I am unsure of how to incorporate PHP within a javascript query and what jQuery functions I will need. I dont want unset onclick="this.disabled=true" if page refresh, code :
<button type="button" class="addb btn btn-primary rounded-pill py-2 btn-block" type="submit" data-voice_sku="'.$row["voice_sku"].'" data-voice_name="'.$row["voice_name"].'" onclick="this.disabled=true">Add to Playlist</button>
If page refresh onclick event unset. how to prevent? Friends I am new to php and i have to submit my coursework in php by 3rd dec, I stuck at one place where i have to upload multiple photo and one can see all the photo he has uploaded and can edit or delete that photo so i have done uploading now i am showing those pics in table by running loop and generating tr and td but now i have two buttons with each row edit and delete now when i clicked on one delete or edit that pic should be delete or give text box to edit description of pic, Please help me how to do that....... If you look at this form: kmkwebdevelopment.com/formtest/upload.php you will see that when you click on the "add another upload box" button, instead of it adding another upload box, it is submitting the form for some reason. Can anyone see where the error lies? Relevant snippet of code below: <?php //deafult number of upload boxes $upload_quant = 4; //if the user increased the number of boxes if(isset($_POST['increase_upload'])) { //increasing the number of upload boxes $upload_quant = $_POST['previous_upload'] + 1; } $upload_quantity = $_POST['previous_upload']; //getting all the names into an array $uplaoded_array = array(); for($i=0;$i<$upload_quantity;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; $get_upload_name = $_POST['$upload_name']; array_push($uplaoded_array,$get_upload_name); } ?> <form class="uploadform" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" onSubmit="return CheckForm(this);"> <?php IsThereErrors("0", $_iserrors); ?> <input type="hidden" name="_referer" value="<?php echo $_referer ?>"> <input type="hidden" name="_next_page" value="1"> <p class="form_expert_style"><input name="URL" type="text" value=""/></p> <table> <tr> <td>First Name *</td> <td><input type='text' size='30' name='firstname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("firstname", "") ?> value="<?php echo isset($_values["firstname"]) ? htmlspecialchars($_values["firstname"]) : "" ?>"></td> </tr> <tr> <td>Last Name *</td> <td><input type='text' size='30' name='lastname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("lastname", "") ?> value="<?php echo isset($_values["lastname"]) ? htmlspecialchars($_values["lastname"]) : "" ?>"></td> </tr> <tr> <td>E-mail *</td> <td><input type='text' size='30' name='email' onblur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("email", "") ?> value="<?php echo isset($_values["email"]) ? htmlspecialchars($_values["email"]) : "" ?>"></td> </tr> <tr> <td>Company Number *</td> <td><input type='text' size='30' name='companynumber' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("companynumber", "") ?> value="<?php echo isset($_values["companynumber"]) ? htmlspecialchars($_values["companynumber"]) : "" ?>"></td> </tr> <?php for($i=0;$i<$upload_quant;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; echo <<<_END <tr> <td>Upload $ii</td> <td><input class="image" type='file' size='30' name='$upload_name'></td> </tr> _END; } echo <<<_END <tr> <td> <input type="hidden" value="$upload_quant" name = "previous_upload"/> <input type="submit" name="increase_upload" value="Add another upload box" /> </td> <tr> <td><input type="submit" name="SubmitBtn" onClick="CheckForm1();" value="SUBMIT" /></td> </tr> </table> </form> _END; } ?> </html> <?php Thanks Hi! I need help with passing php variable in onclick, can someone please correct code below? Right now the location.href is showing $match_link variable in address bar, it's not reading it. $matchlink = 'onclick="location.href=\'$match_link\';"'; I then echo HTML template... <div class="rankingrow" style="height:28px;background-color:$bg_color" $matchlink> thanks for help. hello all, I inserted a javascript event handler 'onclick' into php code. the onclick has a php variable in it that is supposed to trigger an alert when clicked. I can't figure out how to escape the php variable correctly, so I just left it at the last thing I tried, which I know is wrong. Any help is appreciated. thanks Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function popUp(a) { alert(a); } </script> </head> <body> <?php $gmail ='yaaah'; echo '<p onclick=popUp(\'$gmail\')>lkjlkjlkjlkjlkjlkj</p>'; ?> </body> </html> it is posible to make something like this? <a href="" onclick="refresh('index.php?info=1');"/>Index 1</a> <a href="" onclick="refresh('index.php?info=2');"/>Index 1</a> <a href="" onclick="refresh('index.php?info=3');"/>Index 3</a> and what code do i need to autorealod the index.php?info=(1,2,3) in my Index.php (simple php file with index.php?info=(1,2,3) include) ? Hi everyone, I want to know, will Javascript's onclick on button work in PHP while loop? I mean, If I out "onclick" with function inside html tag, then put html inside echo under while loop. Will JavaScript's onclick work? Like this script below:
$i = 0; while( $i < 5) { echo "<button id='btn' onclick='test()'>Hello</button>"; $i++; }
This loop will create 4 times loop with same echo with onclick, so will onclick call Javascript programming? I am editing this page (attached) and I'm trying to create another button to an external link. I thought it would be as easy as copying and pasting the text to create a second button but that kills the entire page. Any suggestions on how I might do this? This link is internally but the second button I need to open an external URL in a new window. The section of PHP: <div class="clear"></div> <?php // Ask a question about this product ?> <?php if (VmConfig::get('ask_question', 0) == 1) { $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE); ?> <div class="clear"></div> <div class="ask-a-question"> <a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><i class="fas fa-envelope"></i><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a> </div> <?php } ?> <?php // Back To Category Button if ($this->product->virtuemart_category_id) { $catURL = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_id, FALSE); $categoryName = vmText::_($this->product->category_name) ; } else { $catURL = JRoute::_('index.php?option=com_virtuemart'); $categoryName = vmText::_('COM_VIRTUEMART_SHOP_HOME'); } ?>
<?php /** * * Show the product details page * * @package VirtueMart * @subpackage * @author Max Milbers, Eugen Stranz, Max Galt * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: default.php 9292 2016-09-19 08:07:15Z Milbo $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); /* Let's see if we found the product */ if (empty($this->product)) { echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); echo '<br /><br /> ' . $this->continue_link_html; return; } echo shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product)); if(vRequest::getInt('print',false)){ ?> <body onload="javascript:print();"> <?php } ?> <div class="product-container productdetails-view productdetails"> <div class="vm-product-wrap row"> <div class="vm-product-media-img col-sm-5"> <?php echo $this->loadTemplate('images'); $count_images = count ($this->product->images); if ($count_images > 1) { echo $this->loadTemplate('images_additional'); } ?> </div> <!--/.col-sm-5--> <div class="vm-product-details-inner col-sm-7"> <div class="vm-product-title"> <div class="pull-left"> <?php // Product Title ?> <h2><?php echo $this->product->product_name ?></h2> <?php // Product Title END ?> </div> <div class="vm-rating pull-left"> <?php if (VmConfig::get('display_stock', 1)) { ?> <?php if ($this->product->product_in_stock > 0) { ?> <div class="product-in-stock"> <i class="pe pe-7s-check"></i> <?php echo JText::_('VM_IN_STOCK'); ?> <span><?php echo $this->product->product_in_stock; ?></span> </div> <?php } else { ?> <div class="product-in-stock"> <i class="pe pe-7s-less"></i> <?php echo JText::_('VM_OUT_OF_STOCK'); ?> </div> <?php } ?> <?php } ?> <?php echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product)); ?> </div> </div> <?php echo $this->product->event->afterDisplayTitle ?> <?php if (is_array($this->productDisplayShipments)) { echo '<div class="vm-product-shipments">'; foreach ($this->productDisplayShipments as $productDisplayShipment) { echo '<div class="vm-product-shipment">'; echo $productDisplayShipment . '<br />'; echo '</div>'; } echo '</div>'; } //In case you are not happy using everywhere the same price display fromat, just create your own layout //in override /html/fields and use as first parameter the name of your file echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency)); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop')); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal')); ?> <?php if (!empty($this->product->product_s_desc)) { ?> <div class="product-short-description"> <h4><i class="pe pe-7s-note"></i><?php echo JText::_('VM_PRODUCT_SHORT_DESC');?></h4> <?php // Removed line because it was generating <br>: echo nl2br($this->product->product_s_desc); echo $this->product->product_s_desc; ?> </div> <?php } // Product Short Description END ?> <?php // Manufacturer of the Product if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) { echo '<div class="clear"></div><span class="product-manufacturer">' . vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . ':' . $this->loadTemplate('manufacturer') . '</span><div class="clear"></div>'; } ?> <div class="spacer-buy-area"> <?php echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product)); echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product)); ?> </div> <div class="clear"></div> <?php // Ask a question about this product ?> <?php if (VmConfig::get('ask_question', 0) == 1) { $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE); ?> <div class="clear"></div> <div class="ask-a-question"> <a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><i class="fas fa-envelope"></i><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a> </div> <?php } ?> <?php // Back To Category Button if ($this->product->virtuemart_category_id) { $catURL = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_id, FALSE); $categoryName = vmText::_($this->product->category_name) ; } else { $catURL = JRoute::_('index.php?option=com_virtuemart'); $categoryName = vmText::_('COM_VIRTUEMART_SHOP_HOME'); } ?> <div class="back-to-category"> <a href="<?php echo $catURL ?>" class="product-details"><i class="fas fa-folder-open"></i><?php echo vmText::sprintf('COM_VIRTUEMART_CATEGORY_BACK_TO',$categoryName) ?></a> </div> <?php // Product Navigation if (VmConfig::get('product_navigation', 1)) { ?> <hr style="width:100%;" /> <div class="product-neighbours"> <?php if (!empty($this->product->neighbours ['previous'][0])) { $prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE); echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0] ['product_name'], array('rel'=>'prev', 'class' => 'previous-page', 'data-toggle' => 'tooltip', 'title' => $this->product->neighbours ['previous'][0] ['product_name'], 'data-dynamic-update' => '1')); } else { echo '<span class="empty-previous-page fas fa-ban"></span> '; } if (!empty($this->product->neighbours ['next'][0])) { $next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE); echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-toggle' => 'tooltip', 'title' => $this->product->neighbours ['next'][0] ['product_name'],'data-dynamic-update' => '1')); } else { echo '<span class="empty-next-page fas fa-ban"></span>'; } ?> </div> <?php } // Product Navigation END ?> <?php // Product Edit Link echo $this->edit_link; // Product Edit Link END ?> </div> <!--/.col-sm-7--> <div class="clear"></div> </div> <!--/.row--> <div style="margin-top:25px;" class="row"> <div class="col-sm-12"> <?php // PDF - Print - Email Icon if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) { ?> <div class="icons"> <?php $link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id; echo '<span class="pdf-icon">'; echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_icon', false); echo '</span>'; //echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon'); echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',false,true,false,'class="printModal"'); $MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component'; echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false,true,false,'class="recommened-to-friend"'); ?> <div class="clear"></div> </div> <?php } // PDF - Print - Email Icon END ?> <?php // event onContentBeforeDisplay echo $this->product->event->beforeDisplayContent; ?> <div class="products-desc-tab"> <ul id="myTab" class="nav nav-tabs" role="tablist"> <?php if (!empty($this->product->product_desc)) { ?> <li role="presentation" class="active"> <a href="#desc" aria-controls="desc" role="tab" data-toggle="tab"> <i class="pe pe-7s-note"></i><?php echo vmText::_('VM_PRODUCT_DESC_TITLE') ?> </a> </li> <?php } // Product Description END if ($this->showReview) { ?> <li role="presentation"> <a href="#review" data-toggle="tab" aria-controls="review" role="tab"> <i class="pe pe-7s-like2"></i><?php echo JText::_('VM_PRODUCT_REVIEWS');?> </a> </li> <?php } ?> </ul> <div class="tab-content"> <?php if (!empty($this->product->product_desc)) { ?> <div role="tabpanel" class="tab-pane desc fade active in" id="desc"> <div class="product-description"> <?php /** @todo Test if content plugins modify the product description */ ?> <?php echo $this->product->product_desc; ?> </div> </div> <?php } // Product Description END if ($this->showReview) { ?> <div role="tabpanel" class="tab-pane review" id="review"> <?php echo $this->loadTemplate('reviews'); ?> </div> <?php } ?> </div> <div class="clear"></div> </div> <!--/. products-desc-tab--> <?php // Product Packaging $product_packaging = ''; if ($this->product->product_box) { ?> <div class="product-box"> <?php echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box; ?> </div> <?php } // Product Packaging END ?> <?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot')); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true )); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories')); ?> <?php // onContentAfterDisplay event echo $this->product->event->afterDisplayContent; // Show child categories if ($this->cat_productdetails) { echo $this->loadTemplate('showcategory'); } ?> </div> <!--/.col-sm-12--> </div> <!--/.row--> <?php $j = 'jQuery(document).ready(function($) { $("form.js-recalculate").each(function(){ if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) { var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val(); Virtuemart.setproducttype($(this),id); } }); });'; //vmJsApi::addJScript('recalcReady',$j); if(VmConfig::get ('jdynupdate', TRUE)){ /** GALT * Notice for Template Developers! * Templates must set a Virtuemart.container variable as it takes part in * dynamic content update. * This variable points to a topmost element that holds other content. */ $j = "Virtuemart.container = jQuery('.productdetails-view'); Virtuemart.containerSelector = '.productdetails-view'; //Virtuemart.recalculate = true; "; vmJsApi::addJScript('ajaxContent',$j); $j = "jQuery(document).ready(function($) { $('[data-toggle=\"tooltip\"]').tooltip();Virtuemart.stopVmLoading();var msg = '';$('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);$('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);var productCustomization=$('.cd-customization'),cart=$('.cd-cart'),animating=false;initCustomization(productCustomization);$('body').on('click',function(event){if($(event.target).is('body')||$(event.target).is('.cd-gallery')){deactivateCustomization()}});function initCustomization(items){items.each(function(){var actual=$(this),addToCartBtn=actual.find('.add-to-cart'),touchSettings=actual.next('.cd-customization-trigger');addToCartBtn.on('click',function(){if(!animating){animating=true;resetCustomization(addToCartBtn);addToCartBtn.addClass('is-added').find('path').eq(0).animate({'stroke-dashoffset':0},300,function(){setTimeout(function(){updateCart();addToCartBtn.removeClass('is-added').find('.addtocart-button').on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){addToCartBtn.find('path').eq(0).css('stroke-dashoffset','19.79');animating=false});if($('.no-csstransitions').length>0){addToCartBtn.find('path').eq(0).css('stroke-dashoffset','19.79');animating=false}},600)})}});touchSettings.on('click',function(event){event.preventDefault();resetCustomization(addToCartBtn)})})}function resetCustomization(selectOptions){selectOptions.siblings('[data-type=\"select\"]').removeClass('is-open').end().parents('.cd-single-item').addClass('hover').parent('li').siblings('li').find('.cd-single-item').removeClass('hover').end().find('[data-type=\"select\"]').removeClass('is-open')}function deactivateCustomization(){productCustomization.parent('.cd-single-item').removeClass('hover').end().find('[data-type=\"select\"]').removeClass('is-open')}function updateCart(){(!cart.find('.total_products').hasClass('items-added'))&&cart.find('.total_products').addClass('items-added').removeClass('empty_basket');var cartItems=cart.find('span'),text=parseInt(cartItems.text())+1;cartItems.text(text)}});"; vmJsApi::addJScript('vmPreloader',$j); } echo vmJsApi::writeJS(); if ($this->product->prices['salesPrice'] > 0) { echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating)); } ?> </div>
I have a function in JS that i would like to pass 2 variables to. One is an int and one is a string. I am struggling to get the string part right as it needs to be wrapped in quotes. My code is : $out.="<div onclick='newTransactionLine(".$r['id'].",".$r['direction'].")' class='transactionItem btn $class d-block mb-2' data-id='".$r['id']."' >".$r['item']."<br/>£".$r['price']."</div>"; which outputs: <div onclick="newTransactionLine(1,OUT)" class="transactionItem btn btn-primary d-block mb-2" data-id="1">Adult Membership (£85)<br>£85.00</div> When i click the button that gets made, i get a reference error on the word out. I have no doubt it is very simple but i just cannot get this to work for me.
This URL works fine: http://www.adodarts.com/calendarandresults/ This URL works fine: http://www.adodarts.com/calendarandresults/?year=2010®ion=&state= If I select 2009, it does not work: http://www.adodarts.com/calendarandresults/?year=2009®ion=&state= Here is the code: <script type="text/JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } function poptastic(url) { newwindow=window.open(url,'name','height=400,width=525,scrollbars=yes,resizable=yes'); if (window.focus) {newwindow.focus()} } function poptastic1(url) { newwindow=window.open(url,'name','height=550,width=650,scrollbars=yes,resizable=yes'); if (window.focus) {newwindow.focus()} } //--> </script> <div align=center style="background-color:#66CCFF; font-size:18px; font-weight:bolder;"><a href="http://www.adodarts.com/files/ADOPlayoffInformation2010.pdf" target="_blank">Click here for 2010 ADO Playoff Information</a></div> <br> <div align=center style="background-color:#FFCC66; font-size:18px; font-weight:bolder;">Click below for 2010 ADO Regional Results</div> <div align=center style="background-color:#FFCC66; font-size:14px; font-weight:bolder;"><a href="2010-masters">MASTERS</a> - <a href="2010-all-stars">ALL-STARS</a> - <a href="2010-us-team"">US Team</a> - <a href="2010-cricket">Cricket</a></div> <table height=30> <tr><td> </td></td> </table> <form name="form1"> <table align=center> <tr> <td><select name="year" > <option value="">Year</option> <option value="2011">2011</option> <option value="2010">2010</option> <option value="2009">2009</option> </select> </td><td><select name="region"> <option value="">Region</option> <option value="">All Regions</option> <option value="1-1">Region 1-1</option> <option value="1-2">Region 1-2</option> <option value="1-3">Region 1-3</option> <option value="1-4">Region 1-4</option> <option value="1-5">Region 1-5</option> <option value="2-1">Region 2-1</option> <option value="2-2">Region 2-2</option> <option value="2-3">Region 2-3</option> <option value="2-4">Region 2-4</option> <option value="2-5">Region 2-5</option> <option value="3-1">Region 3-1</option> <option value="3-2">Region 3-2</option> <option value="3-3">Region 3-3</option> <option value="3-4">Region 3-4</option> <option value="3-5">Region 3-5</option> <option value="4-1">Region 4-1</option> <option value="4-2">Region 4-2</option> <option value="4-3">Region 4-3</option> <option value="4-4">Region 4-4</option> <option value="4-5">Region 4-5</option> <option value="4-6">Region 4-6</option> <option value="5-1">Region 5-1</option> <option value="5-2">Region 5-2</option> <option value="5-3">Region 5-3</option> <option value="5-4">Region 5-4</option> <option value="5-5">Region 5-5</option> <option value="6-1">Region 6-1</option> <option value="6-2">Region 6-2</option> <option value="6-3">Region 6-3</option> <option value="6-4">Region 6-4</option> <option value="6-5">Region 6-5</option> </select> </td><td><select name="state"> <option value="">State</option> <option value="">All States</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connectictut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Ketucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> </select> </td><td> <input type="submit" value="Filter" onClick="MM_jumpMenu('parent',this,0)"> </td></tr> </table> <strong><em>*Note: Unsanctioned tournaments will not have links</em></strong> </form> <?php $year = $_GET['year']; $region = $_GET['region']; $state = $_GET['state']; if($year == 0) { $year = '2010'; } $dbh=mysql_connect ("localhost", "database", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("adodarts_TournamentCalendar"); $y = "`sdate` >= '2010-01-01' AND `sdate` <= '2010-12-31'"; $r = ""; $s = ""; if($year == 2009) { $y = "`sdate` >= '2009-01-01' AND `sdate` <= '2009-12-31'"; } if($region != "") { $r = " and `region` = '" . $region . "'"; } if($state != "") { $s = " and `state` = '" . $state . "'"; } $query = "SELECT * FROM `ADOSanctionedTournaments` WHERE " . $y . $r . $s . " ORDER BY `sdate`"; $result = mysql_query($query,$dbh) or die(mysql_error()); ?> <table width=100% align=center> <?php while($row = mysql_fetch_array($result)) { $rrn = $row[rrn]; if(substr($row['sdate'],5,2) == 1) { $alphamonth = 'January'; } elseif(substr($row['sdate'],5,2) == 2) { $alphamonth = 'February'; } elseif(substr($row['sdate'],5,2) == 3) { $alphamonth = 'March'; } elseif(substr($row['sdate'],5,2) == 4) { $alphamonth = 'April'; } elseif(substr($row['sdate'],5,2) == 5) { $alphamonth = 'May'; } elseif(substr($row['sdate'],5,2) == 6) { $alphamonth = 'June'; } elseif(substr($row['sdate'],5,2) == 7) { $alphamonth = 'July'; } elseif(substr($row['sdate'],5,2) == 8) { $alphamonth = 'August'; } elseif(substr($row['sdate'],5,2) == 9) { $alphamonth = 'September'; } elseif(substr($row['sdate'],5,2) == 10) { $alphamonth = 'October'; } elseif(substr($row['sdate'],5,2) == 11) { $alphamonth = 'November'; } elseif(substr($row['sdate'],5,2) == 12) { $alphamonth = 'December'; } if($alphamonth != $alphamonthhold) { echo "<tr><td colspan=5 align=center bgcolor=#CCCCCC>"; echo '<div style="color:#0000CC; font-size:14px; font-weight:bold">' . $alphamonth . '</div>'; echo "</td></tr>"; } echo "<tr><td align=center>"; echo substr($row['sdate'],8,2); if(substr($row['sdate'],8,2) != substr($row['edate'],8,2)) { echo "-" . substr($row['edate'],8,2) . " "; } echo "</td><td>"; if($row['filename'] != "" & $row['tournamentdirector'] == ""){ echo "<a href=\"javascript:poptastic1('http://www.adodarts.com/calendar/tournament.php?rrn=$rrn');\">"; echo $row['tournament']; echo "</a>"; } elseif($row['filename'] != "" & $row['tournamentdirector'] != "" & $row['paymentreceived'] == "Y" & $row['adoapproved'] == "Y"){ echo "<a href=\"javascript:poptastic1('http://www.adodarts.com/calendar/tournament.php?rrn=$rrn');\">"; echo $row['tournament']; echo "</a>"; } elseif($row['filename'] == "" & $row['tournamentdirector'] == "" & $row['paymentreceived'] == "Y" & $row['adoapproved'] == "Y"){ echo "<a href=\"javascript:poptastic1('http://www.adodarts.com/calendar/tournament.php?rrn=$rrn');\">"; echo $row['tournament']; echo "</a>"; } else { echo $row['tournament']; } echo "<font color=white>" . $row[rrn] . "</font>"; echo "</td><td align=right>"; echo "$" . number_format($row['purse']); echo "</td><td>"; echo $row['state']; echo "</td><td>"; if($row['results'] != "Y") { echo " "; } else { echo "<a href=\"javascript:poptastic1('http://www.adodarts.com/calendar/results.php?rrn=$rrn&year=$year');\">results</a>"; } echo "</td>"; $alphamonthhold = $alphamonth; } echo "</tr></table>"; ?> </td> </tr> </table> Hi, I'm new to php and just trying to practice with some codes I have. I have a php code to delete an entry from a database, all works well but I want to try to use the 'onclick' event to prompt for confirmation. However, when I add this I end up with a blank page. Then original code was: echo('<p>' . $commenttext . '<a href="adddelete.php?deletecomment=' . $commentid . '">' . 'Delete this Comment</a></p>'); I changed it to: echo('<p>' . $commenttext . '<a href="adddelete.php?deletecomment=' . $commentid . ' onclick='return confirm('Are you SURE you want to delete this comment?')'">' . 'Delete this Comment</a></p>'); Anyone know what the problem could be, or an alternative way to get a confirmation before deleting? Thanks in advance. Hello,
I am trying to make 'onclick img' that will provide a Linux command when clicked.
I've been trying this code:
<body> <?php include("connect.php"); include('Net/SSH2.php'); *** CONNECTION TO DATABASE MYSQL CODE *** if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { $_SESSION['logged'] = true; $ssh = new Net_SSH2('xx.xx.xx.xx'); if (!$ssh->login($info['username'], $info['password'])) { exit('Connection to Linux has failed, please try again.'); } echo '<form action="" method="GET">'; echo '<input type="image" src="start.png" width=100 height=100 name="start" />'; echo '</form>'; if(isset($_GET['start'])) { echo $ssh->setTimeout(5); echo $ssh->exec('(cd '.$info['username'].' ; nohup ./samp03svr &)'); } } } else { $_SESSION['logged'] = null; header("Location: loginfail.php"); } ?> </body>But when I clicked the image, it sends me to "loginfail.php". Please help >< This may not the best place to post this but I'm sure quite a few people here can help. I have an a tag which uses the event trigger "onClick" However when I click on this link the page refreshes. Is there anyway I can stop this? I have copied my code below. <a href=\"#\" class=\"" . $a[$i] . "\" onClick=\"locationValue('" . $a[$i] . "', '" . $_GET['search_type'] . "')\"> Hey guys, I was wondering if it is possible to have a value inserted into a table as someone clicks on a link (in order to count views for example)? thanks! I have 3 images Shown below. What I want to do is add an onclick that will change another variable (lets call it $secondary). So when any one of these are clicked it will change the variable $secondary to whatever I want it to be. (hope that makes sence) <?php $main[0]="<img src='images/00.gif'>"; echo $main[0]; ?> <?php $main[1]="<img src='images/01.gif'>"; echo $main[1]; ?> <?php $main[2]="<img src='images/02.gif'>"; echo $main[2]; ?> Hello everybody There is one word here that I dont get to include the right way, I think because of the issue of single and double quotes. When I replace the variable by its value, it works me alright, but since I have to include this PHP variable ($user) within the onclick JS function, it is problematic. Code: [Select] <?php echo ' <form> <input type="checkbox" name="asset" value="" onclick="getLoggedInUser($user) " /> I am potentially interested in this product service<br /> <div id="txtHint"><b>Note:</b></div> </form> '; By the way, I cant believe the verification code to submit the text. It took me 2 minutes to figure out what they were talking about John, George, Paul, and I had no idea what the hell that was, when I casually thought of the Beatles. so Ringo. I hate that rubbish music. Next time I get verification code like that I go elsewhere. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=308673.0 |