accessing CSS of a inherited element
0 Comments Published June 23rd, 2010 in Programming Tags: No Tags.<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
Chooseafiletoupload:<input name="uploadedfile" type="file"/><br/>
<input type="submit" value="UploadFile" name="Submit"/>
</form>
<?php
if (isset($_POST['Submit'])){
$target_path="upload/";
$target_path=$target_path.basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path)){
$myFile = "upload/".$_FILES['uploadedfile']['name'];
}
else{echo "could not upload";}
[/cc]
Number of Columns and Rows in CSV using php
0 Comments Published March 10th, 2010 in PHP, Programming Tags: No Tags.How to get the # of columns and rows from a csv using php
[Can be useful when parsing a csv, e.g: creating a table in a database from a csv - need to know # of columns]
2 ways
$myFile = "THEFILE.csv";
$row = 0;
if (($handle = fopen($myFile , "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
} echo "Columns = $num"."<br>";
echo "Rows = $row";
fclose($handle);
}
//Just using FOPEN
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
$theData2 = explode ( "\n", $theData);
fclose($fh);
$r2=-1;
$col = $theData2[0];
$piece = explode(",",$col);
$c2 = count($piece);
foreach($theData2 as $line){
$r2++;
}
echo "Columns = $c2 <br>";
echo "Rows = $r2";
How to get url with Jquery and PHP
0 Comments Published February 24th, 2010 in JavaScript, PHP, Programming Tags: No Tags.current URL in address bar
PHP
$pageURL= $pageURL= $_SERVER["REQUEST_URI"].$_SERVER["REQUEST_URI"];
Jquery
$(document).ready(function() {
var pathname = window.location.pathname;
alert (pathname);
});
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
1 Comment 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>
Categories |
Categories
|
Latest Posts
|
||
Latest Photos on Flickr |
||||







