Hi sometimes you may want to disable and enable controls using js. here i will explain how to do this.......
suppose you have these controls in you page which were currently disabled/readonly and our aim is to enable them using js
<input id="myText" name="myText" readonly="" type="text">
<select disabled id="mySelect" name="mySelect"> ,br/><option value="value1">Value1</option>
<option value="value2">Value2</option>
<option value="value3">Value3</option>
</select>"
<input disabled="" id="myCheckbox" name="myCheckbox" type="checkbox" />
<input disabled="" id="myRadio" name="myRadio" type="radio" />
//and finally a button to change status of these controls
<input onclick="changestatus()" type="button" value="ChangeStatus" />
<script type="text/javascript">
function changestatus()
{
document.getElementById("myText").removeAttribute("readonly",false);
document.getElementById("mySelect").removeAttribute("disabled",false);
document.getElementById("myCheckbox").removeAttribute("disabled",false);
document.getElementById("myRadio").removeAttribute("disabled",false);
}
</script>
Thats it once we click on the button ChangeStatus the status will be changed.
To do the reverse you may have to use setAttribute to set the status
eg:: document.getElementById("myText").setAtttribute("readonly",true);
Pages
Friday, December 31, 2010
Wednesday, December 29, 2010
wdcalendar
Yes wdCalendar is same as famous as and as same as google calendar developed using js and php with advanced facilities like drag event and multi-color events.
Handling or merging wdCalendar with your project is so easy......
just create a jqcalendar table inside your database.
and the structure of the table is in setup.sql
Step 1.
Edit datafeed.php in php folder inside wdCalendar folder.
dbconfig.php
class DBConnection{
function getConnection(){
$db = "Your_DB_Name_here";
$server = "Server";//eg : localhost
$username = "db_username";//eg: root
$password ="db_password";//eg: console
mysql_connect($server,$username,$password) or die("Could not connect: " . mysql_error());
mysql_select_db($db) or die("Could not select database: " . mysql_error());
}
}
?>
give your dbname,server,user,password thats it you have linked the db with wdCalendar.
Step 2.
now last step to do is.
there is a file called datafeed.db.php and datafeed.php
rename
1. datafeed.db.php to datafeed.php
2. datafeed.php to any name because datafeed is just a sample file.
Now run your calendar, if you are getting any error then redo from the beginning.
if there is no error, it means you have successfully linked wdCalendar with your project.
Sometimes you may have to use wdCalendar without using default jqcalendar table or using existing table(your own) to add events.........
Posting soon on this......
Handling or merging wdCalendar with your project is so easy......
just create a jqcalendar table inside your database.
and the structure of the table is in setup.sql
Step 1.
Edit datafeed.php in php folder inside wdCalendar folder.
dbconfig.php
class DBConnection{
function getConnection(){
$db = "Your_DB_Name_here";
$server = "Server";//eg : localhost
$username = "db_username";//eg: root
$password ="db_password";//eg: console
mysql_connect($server,$username,$password) or die("Could not connect: " . mysql_error());
mysql_select_db($db) or die("Could not select database: " . mysql_error());
}
}
?>
give your dbname,server,user,password thats it you have linked the db with wdCalendar.
Step 2.
now last step to do is.
there is a file called datafeed.db.php and datafeed.php
rename
1. datafeed.db.php to datafeed.php
2. datafeed.php to any name because datafeed is just a sample file.
Now run your calendar, if you are getting any error then redo from the beginning.
if there is no error, it means you have successfully linked wdCalendar with your project.
Sometimes you may have to use wdCalendar without using default jqcalendar table or using existing table(your own) to add events.........
Posting soon on this......
Friday, December 24, 2010
javascript
you can split a string in javascript
var str = "Here is my string";
var res_array = str.split(" ");
/*
array contains splitted values
*/
var search_str = str.search(/my string/i);
if(search_str!=-1)
var search_res ="found";
/* for multiple string search*/
var search_str = str.search(/my string|here/i);
if(search_str!=-1)
var search_str = "string found");
//remember to use -1 in if condition.
var str_replace = str.replace("string","code");
//results in str_replace = "Here is my code"
var str = "Here is my string";
var res_array = str.split(" ");
/*
array contains splitted values
*/
var search_str = str.search(/my string/i);
if(search_str!=-1)
var search_res ="found";
/* for multiple string search*/
var search_str = str.search(/my string|here/i);
if(search_str!=-1)
var search_str = "string found");
//remember to use -1 in if condition.
var str_replace = str.replace("string","code");
//results in str_replace = "Here is my code"
Thursday, December 2, 2010
Symfony combine more than one table in Criteria
adding criteria with more than one table is easy than you think......
$id = '1';
$cri1 = new Criteria();
$cri1->add(TblName1Peer::ID,$id);
$cri_res1 = TblName1Peer::doSelectOne($cri1);
//if you you doSelectOne
$id = $cri_res1->getId();
$cri2 = new Criteria();
$cri2->add(TblName2Peer::ID,$id);
$cri_res = TblName2Peer::doSelect($cri2);
$this->ret_val = array_unique($cri_res);
//if you use doSelect as this
$cri_res = TblName1Peer::doSelect($cri1);
foreach($cri_res as $res)
{
$val []= TblName1Peer::retrieveByPk($res->getId());
}
$cri = new Criteria();
$cri->add(blName2Peer::ID,$val[0]);
$cri_res = TblName2Peer::doSelect($cri);
$this->ret_val = array_unique($cri_res);
Please notice me if something wrong.......
$id = '1';
$cri1 = new Criteria();
$cri1->add(TblName1Peer::ID,$id);
$cri_res1 = TblName1Peer::doSelectOne($cri1);
//if you you doSelectOne
$id = $cri_res1->getId();
$cri2 = new Criteria();
$cri2->add(TblName2Peer::ID,$id);
$cri_res = TblName2Peer::doSelect($cri2);
$this->ret_val = array_unique($cri_res);
//if you use doSelect as this
$cri_res = TblName1Peer::doSelect($cri1);
foreach($cri_res as $res)
{
$val []= TblName1Peer::retrieveByPk($res->getId());
}
$cri = new Criteria();
$cri->add(blName2Peer::ID,$val[0]);
$cri_res = TblName2Peer::doSelect($cri);
$this->ret_val = array_unique($cri_res);
Please notice me if something wrong.......
Symfony1.4 writing criteria and return array
it's really so simple to write a criteria and return an array
$cri = new $Criteria();
$cri->add(TblNamePeer::ID,"value");
$cri_res = TblNamePeer::doSelect($cri);
$ret_val = array_unique($cri_res);
$this->ret_val = $ret_val;
$cri = new $Criteria();
$cri->add(TblNamePeer::ID,"value");
$cri_res = TblNamePeer::doSelect($cri);
$ret_val = array_unique($cri_res);
$this->ret_val = $ret_val;
Subscribe to:
Comments (Atom)