textbox hint and empty for mobile too

<input id=”textbox” type=”text” value=”Search” />

<input type=”text” onblur=”if(this.value==”){this.value=’Search'; this.style.color=’#555′}” onclick=”if(this.value==’Search’){this.value=”; this.style.color=’#000′}” value=”Search” id=”textbox” />

Multiple database connection in php

index.php

<?php
$hostname =’localhost';
$username =’root';
$password =”;
$dbh1 = mysql_connect($hostname, $username, $password);
$dbh2 = mysql_connect($hostname, $username, $password, true);

mysql_select_db(‘database1′, $dbh1);
mysql_select_db(‘database2′, $dbh2);
$result1=mysql_query(‘select * from table1′, $dbh1);
$result2=mysql_query(‘select * from table1′, $dbh2);
while($row1=mysql_fetch_array($result1))
{
print_r($row1);
}
echo “<br>”;
while($row2=mysql_fetch_array($result2))
{
print_r($row2);
}
?>

 

database1.sql

— phpMyAdmin SQL Dump
— version 2.10.1
— http://www.phpmyadmin.net

— Host: localhost
— Generation Time: Jan 08, 2010 at 12:31 PM
— Server version: 5.0.45
— PHP Version: 5.2.5

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;


— Database: `database1`

— ——————————————————–


— Table structure for table `table1`

CREATE TABLE `table1` (
`id` int(2) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;


— Dumping data for table `table1`

INSERT INTO `table1` (`id`, `name`) VALUES
(1, ‘aa’),
(2, ‘bb’);
database2.sql

— phpMyAdmin SQL Dump
— version 2.10.1
— http://www.phpmyadmin.net

— Host: localhost
— Generation Time: Jan 08, 2010 at 12:31 PM
— Server version: 5.0.45
— PHP Version: 5.2.5

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;


— Database: `database2`

— ——————————————————–


— Table structure for table `table1`

CREATE TABLE `table1` (
`id` int(2) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;


— Dumping data for table `table1`

INSERT INTO `table1` (`id`, `name`) VALUES
(1, ‘aaqqqqqqqqqqqqqqqq’),
(2, ‘bbsssssssssssssssssssssssss’);

javascript validation on array check box

suppose your checkbox like this

 

<p style=”margin-left:20px;”>
<label><input type=”checkbox” name=”services[]” id=”services” value=”Copy Writing”/> Copy Writing</label>
<label><input type=”checkbox” name=”services[]” id=”services” value=”Brand Development”/> Brand Development</label>
<label><input type=”checkbox” name=”services[]” id=”services” value=”Press Advertising”/> Press Advertising</label>
<label style=”margin-left:40px;”><input type=”checkbox” name=”checkbox13″ id=”services”  value=”Photography”/> Photography </label>
<label style=”margin-left:8px;”><input type=”checkbox” name=”services[]” id=”services” value=”Others” /> Others</label>
</p>

 

and you want javascript validation of this array format checkbox

you can do by this way:

var chks = document.form1_feed.elements[‘services[]’];
var hasChecked = false;
//alert(chks.length);
for (var i = 0; i < chks.length; i++)
{
if (chks[i].checked)
{
hasChecked = true;
break;
}
}
if (!hasChecked){
alert(“Please select at least one.”);
chks[0].focus();
return false;
}

 

9844542127