Jquery Image area select Z-index issue
0 Comments Published February 8th, 2010 in JavaScript, Programming Tags: No Tags.If you try using PHP & jQuery image upload and crop [http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/]
with some sort of modal like popup functionality, you will notice that the imgareaselect selection does not have proper zindex value,
although this plugin is using 0.6 version and 0.8/0.9 claims to have added zindex option, still doesnt seem to work
so grab 0.6 from link above and change the following line in the .js file
$a.add($o).css({ display: ‘none’, position: fixed ? ‘fixed’ : ‘absolute’, overflow: ‘hidden’,
zIndex: zIndex > 0 ? zIndex : null });
to
$a.add($o).css({ display: ‘none’, position:’fixed’ : ‘absolute’, overflow: ‘hidden’,
zIndex: ‘999′ });
Jquery UI demos http://jqueryui.com/demos/
CSS menu generator http://www.cssmenumaker.com/
Simple 2 column div layout [css]
0 Comments Published October 8th, 2009 in Programming Tags: No Tags.Simple 2 column layout with a header using css.
The HTML
{
margin:0px auto;
width:800px;
}
div#header
{
width:800px;
height:30px;
float:left;
}
div#sidebar
{
width:100px;
float:left;
height:30px;
}
div#main
{
width:700px;
height:30px;
float:left
}
RESULT [copying image of this http://www.james-blogs.com/2009/05/15/website-layouts-with-sidebars/]
[so result is actually sidebar first then content]

Todays date selected in date fields
0 Comments Published September 2nd, 2009 in PHP, Programming Tags: No Tags.POOR mans way of doing this, 3 combo box’s with day/month/year, with todays date already selected,
using my previous changing variable name method
$day = date("d");
$month = date("m");
$year = date("y");
${'daysel'.$day} = 'selected="selected"';
${'monthsel'.$month} = 'selected="selected"';
${'yearsel'.$year} = 'selected="selected"';
?>
<html>
<form>
<table>
<tr>
<td><select name="day">
<option value="01" <?php echo $daysel01; ?>>1</option>
<option value="02" <?php echo $daysel02; ?>>2</option>
<option value="03" <?php echo $daysel03; ?> >3</option>
<option value="04" <?php echo $daysel04; ?>>4</option>
<option value="05" <?php echo $daysel05; ?>>5</option>
<option value="06" <?php echo $daysel06; ?>>6</option>
<option value="07" <?php echo $daysel07; ?>>7</option>
<option value="08" <?php echo $daysel08; ?>>8</option>
<option value="09" <?php echo $daysel09; ?>>9</option>
<option value="10" <?php echo $daysel10; ?>>10</option>
<option value="11" <?php echo $daysel11; ?>>11</option>
<option value="12" <?php echo $daysel12; ?>>12</option>
<option value="13" <?php echo $daysel13; ?>>13</option>
<option value="14" <?php echo $daysel14; ?>>14</option>
<option value="15" <?php echo $daysel15; ?>>15</option>
<option value="16" <?php echo $daysel16; ?>>16</option>
<option value="17" <?php echo $daysel17; ?>>17</option>
<option value="18" <?php echo $daysel18; ?>>18</option>
<option value="19" <?php echo $daysel19; ?>>19</option>
<option value="20" <?php echo $daysel20; ?>>20</option>
<option value="21" <?php echo $daysel21; ?>>21</option>
<option value="22" <?php echo $daysel22; ?>>22</option>
<option value="23" <?php echo $daysel23; ?>>23</option>
<option value="24" <?php echo $daysel24; ?>>24</option>
<option value="25" <?php echo $daysel25; ?>>25</option>
<option value="26" <?php echo $daysel26; ?>>26</option>
<option value="27" <?php echo $daysel27; ?>>27</option>
<option value="28" <?php echo $daysel28; ?>>28</option>
<option value="29" <?php echo $daysel29; ?>>29</option>
<option value="30" <?php echo $daysel30; ?>>30</option>
<option value="31" <?php echo $daysel31; ?>>31</option>
</select>
<select name="month">
<option value="01" <?php echo $monthsel01; ?>>January</option>
<option value="02" <?php echo $monthsel02; ?>>Febuary</option>
<option value="03" <?php echo $monthsel03; ?>>March</option>
<option value="04" <?php echo $monthsel04; ?>>April</option>
<option value="05" <?php echo $monthsel05; ?>>May</option>
<option value="06" <?php echo $monthsel06; ?>>June</option>
<option value="07" <?php echo $monthsel07; ?>>July</option>
<option value="08" <?php echo $monthsel08; ?>>August</option>
<option value="09" <?php echo $monthsel09; ?>>September</option>
<option value="10" <?php echo $monthsel10; ?>>October</option>
<option value="11" <?php echo $monthsel11; ?>>November</option>
<option value="12" <?php echo $monthsel12; ?>>December</option>
</select>
<select name="year">
<option value="2009" <?php echo $yearsel09; ?>>2009</option>
<option value="2010" <?php echo $yearsel10; ?>>2010</option>
<option value="2011" <?php echo $yearsel11; ?>>2011</option>
</select>
</td>
</form>
</html>
Check for checkbox’s [PHP]
0 Comments Published August 27th, 2009 in PHP, Programming Tags: No Tags.To check which checkbox is selected, or if both are selected, in PHP
checker in php
$state=$_POST['coupons'];
foreach ($state as $statename)
{
$x = $statename;
$ugh .= $x;
}
if 1 is selected, result will be 1
if 2 is selected result will be 2
if both are selected, result will be 12
go forward using if($ugh == ‘12′){ } etc
Add more emails to send mail / multiple recipients / refer a friend
1 Comment Published August 18th, 2009 in JavaScript, Programming Tags: No Tags.If you need to add several emails, to refer a friend without asking the user to add all in separated by commas !
Code below provides separate field, where user can add individual email and press ADD, emails are then added automatically, separated by a comma “,” . There is an extra comma at the end but eliminate with any server side language etc

function exec(){
mains.to.value+=refer.email.value+",";
refer.email.value ="";
}
</script>
<form id="refer" onSubmit="exec();">
<input type="text" name="email"/>
<A href="#" onClick="exec();">ADD</a>
</form>
<form id="mains">
<input type="text" id="to" /><br>
<textarea id="message" rows="5"></textarea><br>
<input type="submit" value="submit"/>
</form>
above code, does not work when using a doctype so try this instead
document.reg.elements[0].value += document.refer.elements[0].value+",";
document.refer.elements[0].value = "";
}
Make sure the forms have the ‘name’ attribute as reg and refer, does not work when set as id [the way it is in the previous example]
And with jquery + validation [http://bassistance.de/jquery-plugins/jquery-plugin-validation/]
<script type="text/javascript" src="scripts/jquery.validate.js"></script>
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() {
var email = $('#email').val()+","+$('#to').val();
$("input#to").val(email);
$("input#email").val("");
}
});
$(document).ready(function(){
$("#refer").validate({
rules: {
email:{required:true, email: true}},
messages: {
email: {required: ' Required', email:' Not Valid'}
},
errorPlacement: function(error, element) {
error.insertAfter(element.next())
}
});
});
</script>
Removing duplicates from several CSV/Excel files.
0 Comments Published August 5th, 2009 in PHP, Programming Tags: No Tags.One can use ‘remove duplicates’ in excel but what if there are over 200k records, split into several csv files/spread sheets.
Easiest solution is to upload to database and add a checking method before hand.
1-Check if email already exists in table
2-If email does not exist then add email to table
ini_set('max_execution_time', 0);
//connect to database/table
$array = file("1.csv");
foreach ($array as $line1)
{
$line2 = trim($line1);
echo $line2;
echo "<Br>";
$queryString ="SELECT email FROM tempnew WHERE email = '$line2'";
$result = mysql_query($queryString);
$num_rows = mysql_num_rows($result);
if($num_rows == 0)
{
$queryString2 ="INSERT INTO tempnew(email) VALUES ('$line2')";
$result2 = mysql_query($queryString2);
}
}
?>
above method was used to get unique email records
PHPlist list only displaying 1-50
0 Comments Published July 28th, 2009 in PHP, Programming Tags: No Tags.Bug where phplist only displays 1-50 in a list, when more users exist [the back < and next > buttons do not function ]
source: http://mantis.phplist.com/view.php?id=15282
Jquery/PHP Irish mobile number validation [regular expressions]
0 Comments Published July 28th, 2009 in JavaScript, PHP, Programming Tags: No Tags.PHP
$pattern = "/^(083|086|085|086|087)\d{7}$/";
$phone = "087343266";
if (preg_match($pattern,$phone)) echo "Match";
else echo "Not match";
Jquery
return /^(083|086|085|086|087)\d{7}$/.test(value);}, " Not Valid");
$(document).ready(function(){
$("#reg").validate({
rules: {
mobile:{required:true,
number:true,
minlength:10,
phoneNumber:true
}},








