I wish to add a "S" prefix(without quotes) to my $tranid, if user select "SH" from the dropdown list.
So it will become S$tranid, so it will become S000001
i was trying concat previously but seems like i mess up and it doesnt work at all.
#This is my strsql query
/** Start To Save New record **/
if($action == "SAVE_DATA")
{
if($tranid == "")
{
$strSQL = "select cs.getInvNo('SH') as tranid; ";
$result = mysql_query($strSQL) or die ("sql error in retrieving trans id.");
if ($row = mysql_fetch_array($result))
{
$tranid = $row['tranid'];
}
}
$strSQL = "insert into cs.cs_inv_header(inv_no,inv_date,inv_so,inv_bill_to,inv_ship_to,inv_loc,";
$strSQL .="inv_cust_code,inv_po,inv_term,inv_curr,inv_ship_via,inv_status,inv_cby,inv_cdate) ";
$strSQL .= "values('$tranid','$shipDate','$so','$custNo','$shipTo','$loc','$custNo','$ref',";
$strSQL .= "'$term','$curr','$shipVia','Y','".$_SESSION['SYS_CS']['USER_ID']."',now());";
mysql_query($strSQL,$link) or die ("sql error on inserting cs.cs_inv_header.");
unset ($strSQL);
$strSQL = "insert into cs.cs_inv_det(invd_no,invd_part,invd_desc,invd_qty,invd_uom,invd_cost,";
$strSQL .="invd_total,invd_vend_part,invd_rmk_ori,invd_rmk,invd_cby,invd_cdate) ";
$strSQL .= "values('$tranid','$part','$desc',$qty,'$uom',$cost,$total,'$custPart','$rmk',";
$strSQL .= "'".mysql_real_escape_string($rmk)."','".$_SESSION['SYS_CS']['USER_ID']."',now());";
mysql_query($strSQL,$link) or die ("sql error on inserting cs.cs_inv_det.");
unset ($strSQL);
echo "<div class=std align=center>Invoice : $tranid Successfully created...</div>";
$tranid = "";
$so = "";
$custNo = "";
$term = "";
$ref = "";
$shipVia = "DDP";
$curr = "";
$part = "";
$uom = "";
$cost = "";
$qty = "";
$total = "";
$desc = "";
$rmk = "";
$loc= "";
}
/** End of Saving new record **/
#this is my dropdown menu code
<select name="selLoc">
<option value = "">--Please Select--</option>
<option value = "HB" <? if($loc=='HB') echo 'selected' ?>>HB-Thailand</option>
<option value = "HH" <? if($loc=='HH') echo 'selected' ?>>HH-Thailand</option>
<option value = "MH" <? if($loc=='MH') echo 'selected' ?>>MH-Malaysia</option>
<option value = "SH" <? if($loc=='SH') echo 'selected' ?>>SH/option>
</select></td>
You can simply do like this on the values line
$strSQL .="values('S$tranid','$part','$desc',$qty,'$uom',$cost,$total,'$custPart','$rmk',";
I want to add a dropdown at checkout page which has option of pick up time and pickupdate. currently I added shipping methods in dropdown I want to add pick up date and time instead of it.
<?php if (($_shippingRateGroups = $this->getEstimateRates())): ?>
<form id="co-shipping-method-form-drop" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>">
<select id='drop_estimate_method' name="estimate_method">
<option value='-1'>Please Select Shipping Method</option>
<?php
foreach ($_shippingRateGroups as $code => $_rates) {
$str = $this->getCarrierName($code);
foreach ($_rates as $_rate){
$str2 = $str . ' - ' . $_rate->getMethodTitle();
$_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
$_incl = $this->getShippingPrice($_rate->getPrice(), true);
$str2 .= ' ['. $_excl;
if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl) {
$str2 .= ' '. $this->__('Incl. Tax'); echo $_incl;
}
$str2 .= '] ';
?>
<option <?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' selected="selected"' ?> value="<?php echo $this->htmlEscape($_rate->getCode()) ?>"><?php echo $str2;?></option>
<?php }
} ?>
</select>
</form>
<script type="text/javascript">
document.observe("dom:loaded", function() {
$('drop_estimate_method').observe('change',function(){
if($('drop_estimate_method').getValue() == -1){
alert('Please Select Shipping Method');
}else{
$('co-shipping-method-form-drop').submit();
}
});
});
</script>
<?php endif; ?>
Datalist attribute is not working in Google chrome, it is working fine in Firefox
Please have a look here http://prntscr.com/arny81
Thanks for your help in advance.
HTML
<td><input onkeyup="showCustomers(this.value)" placeholder="Enter Customer Name" list="selectCust" name="Cno" />
<datalist id="selectCust">
</datalist>
</td>
Javascript
function showCustomers(str) {
if (str.length == 0) {
document.getElementById("selectCust").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("selectCust").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET", "getCustomers.php?q=" + str, true);
xmlhttp.send();
}
}
getCustomers.php File
<?php include('conn.php'); ?>
<?php // get the q parameter from URL
$q = $_REQUEST["q"];
// lookup all hints from array if $q is different from ""
if ($q !== "") {
$q = strtolower($q);
$len=strlen($q);
$sql2 = 'SELECT Customer_Name as Cname,No from customers order by Customer_Name';
$result2 = mysqli_query($connection, $sql2) or die(mysqli_error($connection));
if (mysqli_num_rows($result2) > 0) {
?><option value=""></option><?php
// output data of each row
while($row2 = mysqli_fetch_assoc($result2)) {
if (stristr($q, substr($row2["Cname"], 0, $len))) { ?>
<option value="<?php
echo $row2['No']; ?>"><?php echo $row2["Cname"]; ?></option>
<?php } } ?>
<?php } } ?>
I have not used CSS at all.
Target the ID in your CSS instead, that should work fine.
HTML:
<datalist id="dl">
Your content goes here
</datalist>
CSS:
#dl {
display: block;
}
This works fine in Chrome or any other browser.
A search result with pagination:
I have created this for my database search results with pagination
<?php
$con = mysql_connect("server","some_user","password"); // Enter hostname,user,password
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// select database
mysql_select_db("some_db", $con);
$output = '';
//collect
if(isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
//pagination code
$query = mysql_query("SELECT * FROM some_table WHERE Title Like '%$searchq%'"); //Counting total number of rows in the table 'data',
$total_rows = mysql_num_rows($query);
// setup configuration//
//step:3
$base_url = 'http://localhost/php_search/New/index.php'; //Provide location of you index file
$per_page = 1; //number of results to shown per page
$num_links = 8; // how many links you want to show
$total_rows = $total_rows;
$cur_page = 1; // set default current page to 1
//now we will extract information from url//
//step:4
if(isset($_GET['search']))
{
$cur_page = $_GET['search'];
$cur_page = ($cur_page < 1)? 1 : $cur_page; //if page no. in url is less then 1 or -ve
}
// calculate limit and offset, it'll will be used for Sql Query//
//step:5
$offset = ($cur_page-1)*$per_page; //setting offset
$pages = ceil($total_rows/$per_page); // no of page to be created
//Calculate the start and end page numbers for pagination links//
//step:6
$start = (($cur_page - $num_links) > 0) ? ($cur_page - ($num_links - 1)) : 1;
$end = (($cur_page + $num_links) < $pages) ? ($cur_page + $num_links) : $pages;
//query the database with calculated OFFSET //
//step:7
$res = mysql_query("SELECT * FROM some_table WHERE Title Like '%$searchq%' LIMIT ".$per_page." OFFSET ".$offset);
mysql_close($con);
//pagination code
if(isset($res))
{
while($result = mysql_fetch_array($res))
{
$title = $result['Title'];
$name = $result['name'];
$description = $result['Description'];
$output .='<div><h1>'.$title.'<br>'.$name.'</h1><br>'.$description.'</div>';
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="search" placeholder="Search here" />
<input type="submit" value="search" />
</form>
<?php print("$output"); ?>
<div id="pagination">
<div id="pagiCount">
<?php
if(isset($pages))
{
if($pages > 1)
{ if($cur_page > $num_links) // for taking to page 1 //
{ $dir = "first";
echo '<span id="prev"> '.$dir.' </span>';
}
if($cur_page > 1)
{
$dir = "prev";
echo '<span id="prev"> '.$dir.' </span>';
}
for($x=$start ; $x<=$end ;$x++)
{
echo ($x == $cur_page) ? '<strong>'.$x.'</strong> ':''.$x.' ';
}
if($cur_page < $pages )
{ $dir = "next";
echo '<span id="next"> '.$dir.' </span>';
}
if($cur_page < ($pages-$num_links) )
{ $dir = "last";
echo ''.$dir.' ';
}
}
}
?>
</div>
</div>
</body>
</html>
I have posted this code with which i am not getting any result on choosing another page
The pagination do occurs but on clicking to the second page there is no search result
Any help please
you pass the page number as "search" parameter
?search='.($cur_page+1)
but collect data only when $_POST['search'] is set
if(isset($_POST['search'])) {
so when you click a page link, you only have $_GET['search'] set, not $_POST['search']
I want to disable choose an option in configurable products drop-down.Rather it should automatically select a default product. Where and what to edit?
You can have those changes in the following file.
app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/catalog/product/view/type/options/configurable.phtml
And Better work with "Template Path Hints" Enabled from the backend. You will know what and where you need to customize.
UPDATE:
Open this file:
/app/design/frontend/default/your_theme/template/catalog/product/view/type/options/configurable.phtml
Right below
var spConfig = new Product.Config(< ?php echo $this->getJsonConfig() ?>);
add this JavaScript code:
//we create new function
spConfig.setInitialState = function(dropdown_id)
{
//select dropdown
var dropdown = $(dropdown_id);
//remove empty option from dropdown so it is not selectable after initial selection
dropdown[0].remove();
//change selections in dropdowns
for(index = 0; index < dropdown.length; index++)
{
if(dropdown[index].value != "")
{
dropdown.selectedIndex = index;
var element = dropdown;
var event = 'change';
//fire events
if(document.createEventObject)
{
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else
{
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true );
return !element.dispatchEvent(evt);
}
}
}
};
<?php foreach($_attributes as $_attribute): ?>
spConfig.setInitialState("attribute< ?php echo $_attribute->getAttributeId() ?>")
<?php endforeach; ?>
For more information See Here and more Here
Full Working file
/app/design/frontend/default/your_theme/template/catalog/product/view/type/options/configurable.phtml
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
//we create new function
spConfig.setInitialState = function(dropdown_id)
{
//select dropdown
var dropdown = $(dropdown_id);
//remove empty option from dropdown so it is not selectable after initial selection
dropdown[0].remove();
//change selections in dropdowns
for(index = 0; index < dropdown.length; index++)
{
if(dropdown[index].value != "")
{
dropdown.selectedIndex = index;
var element = dropdown;
var event = 'change';
//fire events
if(document.createEventObject)
{
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else
{
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true );
return !element.dispatchEvent(evt);
}
}
}
};
<?php foreach($_attributes as $_attribute): ?>
spConfig.setInitialState("attribute<?php echo $_attribute->getAttributeId() ?>")
<?php endforeach; ?>
</script>
<?php endif;?>