Monday, May 17, 2010

Renaming id name in javascript

old is old id where we are going to rename it to new

function renameID()
{
document.getElementById("old").id = "new";
}

onclick="renameID()"

Wednesday, May 5, 2010

Adding and removing text box Which also insert a row next or Beneath the row

In this program We can add the row and we can also insert the row beneath the row
and we can remove the row.... dynamic select box value from database.. can be added each time to row

this program is calculating tax i did in html u can make it use in php by give the tax value from data base presently its static value

Remove all opening and closed BR tags and then run
ADD THIS IN HEAD TAG



<SCRIPT language="javascript">


function insRow1(id)
{
var m = document.getElementById(id).rowIndex;
++m;
var x=document.getElementById('myTable').insertRow(m);
id = ++id;
var y=x.insertCell(0);
var z=x.insertCell(1);
var g=x.insertCell(2);
var w=x.insertCell(3);
var h=x.insertCell(4);
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
--rowCount;
var divIdName = 'my'+rowCount+'Div';
x.setAttribute('id',divIdName);
var rowCount1=--rowCount;
y.innerHTML="<input type='text' value='' onkeyup=total2() id="+divIdName+"FT>";
z.innerHTML="<input type='text' value='' onkeyup=total2() id="+divIdName+"ST>";
g.innerHTML =table.rows[1].cells[2].innerHTML;
w.innerHTML="<input type='button' id="+divIdName+"Add onclick=insRow1('"+divIdName+"') value='Insert row'>";
h.innerHTML="<input type='button' id="+divIdName+"Del onclick=deleteRow('"+divIdName+"') value='Delete'>";
g.firstChild.setAttribute('id',divIdName+'Sel');
g.firstChild.setAttribute('onchange','total2()');
}


function deleteRow(tableID) {
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
var m = document.getElementById(tableID).rowIndex;
table.deleteRow(m);
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
var v=0;
for(var m=1;m<rowCount;m++) {
var Ft=document.getElementById(table.rows[m].cells[0].firstChild.getAttribute('id')).value;
var St=document.getElementById(table.rows[m].cells[1].firstChild.getAttribute('id')).value;
var Sel=document.getElementById(table.rows[m].cells[2].firstChild.getAttribute('id')).value
if(!Ft) {
Ft=0;
}
if(!St) {
St=0;
}

var to= parseInt(St) * parseInt(Ft);
if(!Sel) {
var tax=0;
} else {
var tax=to*(Sel/100);
}
to=parseInt(to)+parseFloat(tax);
if(Ft && St) {
v=parseFloat(v)+parseFloat(to);
}
}
document.getElementById('total1').value=v;
}

function total2() {
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
var v=0;
for(var m=1;m<rowCount;m++) {
var Ft=document.getElementById(table.rows[m].cells[0].firstChild.getAttribute('id')).value;
var St=document.getElementById(table.rows[m].cells[1].firstChild.getAttribute('id')).value;
var Sel=document.getElementById(table.rows[m].cells[2].firstChild.getAttribute('id')).value;
if(!Ft) {
Ft=0;
}
if(!St) {
St=0;
}
var to= parseInt(St) * parseInt(Ft);
if(!Sel) {
var tax=0;
} else {
var tax=to*(Sel/100);
}
to=parseInt(to)+parseFloat(tax);
if(Ft && St) {
v=parseFloat(v)+parseFloat(to);
}
}
document.getElementById('total1').value=v;
}
</SCRIPT>





<span style="font-weight:bold;">ADD THIS IN BODY TAG </span>
<textarea rows="10" cols="50">
<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
Total    <input type="text" id="total1" value=''>

<table id="myTable" border="1">
<tr>
<th>Qty</th>
<th>Price</th>
<th>Tax</th>
<th>Add</th>
<th>Delete</th>
</tr>
<tr id="my1Div">

<td><input type='text' onkeyup="total2()" value="" id="my1DivFT" ></td>
<td><input type='text' value='' id="my1DivST" onkeyup="total2()"></td>
<td><select name=select1 id=my1DivSel onchange="total2()">
<option value=''>Select</option>
<option value='1'>Value 1</option>
<option value='2'>Value 2</option>
<option value='3'>Value 3</option>
</select></td>
<td><input type="button" onclick="insRow1('my1Div')" value="Insert row"></td>
</tr>
</table>
</form>

Tuesday, March 23, 2010

Puttanna Kanagal (1933-1985)




Puttanna Kanagal's Directional Movies

Belli Moda (1966) (Silver Cloud)
Mallammana Pavaada (1969) (Mallamma's Magic)
Kappu Bilupu (1969) (Black and White)
Gejje Pooje (1969) (Mock Marriage)
Karulina Kare (1970) (The Voice of Affection)
Sakshatkara (1971) (The Realisation)
Sharapanjara (1971) (Cage of Arrows)
Nagara Haavu (1972) (The Cobra)
Edakallu Guddada Mele (1973) (On the Edakallu Hillock)
Upasane (1974) (The Devotion) starring Aarathi, Seetaram.
Katha Sangama (1975) (Collection of Stories)
Shubhamangala (1975) (Happy Ending)
Bili Hendthi (1975) (White Wife)
Phalithamsha (1976) (The Result)
College Ranga (Kaaleju ranga) (1976) (The College Stage)
Paduvaaralli Pandavaru (1978) (Pandavas of Paduvarahalli)
Dharmasere (1979) (The Religious Bind)
Ranganayaki (1981) (The Heroine of the Stage)
Maanasa Sarovara (1982)
Dharani Mandala Madhyadolage (1983) (At the Centre of Earth)
Amrutha Ghalige (1984) (The Auspicious Moment)
Runamukthalu (1984) (Devoid of Debt)
Masanada Hoovu (1984)
Saavira Mettilu (2006) (Thousand Steps)

Friday, March 12, 2010

Adding dates function in Php and Zend

in zend and php i wrote one small function which is used for adding days,months and year to a date and Format is YYY-MM-dd

Zend
$date = new Zend_Date();
$disbursedDate1='2010-03-11';
$date->set($disbursedDate1,Zend_Date::DATES);
$disbursedDate1=$date->toString("YYY-MM-dd");
$date->set($disbursedDate1,Zend_Date::DATES);
$disbursedDate1=$date->toString("YYY-MM-dd");
$cd = $this->add_dateAction($disbursedDate1,0,1,0);
echo $cd;



Php
$disbursedDate1='2010-03-11';
$cd = $this->add_dateAction($disbursedDate1,0,1,0);
echo $cd;



Function

function add_dateAction($givendate,$day=0,$mth=0,$yr=0)
{
$cd = strtotime($givendate);
$newdate = date('Y-m-d', mktime(date('h',$cd),
date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
date('d',$cd)+$day, date('Y',$cd)+$yr));
return $newdate;
}



Note:- in zend formate is changed so i used this function to over that prob
in Zend default formate is YYYY-DD-MM ,but we can change what every formate we want by Zend_Local

Thursday, February 25, 2010

ಕನ್ನಡ ಕವಿ ,ರಸ್ಟ್ರ-ಕವಿ-ಕುವೆಂಪು

ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!
ರೂಪರೂಪಗಳನು ದಾಟಿ, ನಾಮಕೋಟಿಗಳನು ಮೀಟಿ,
ಎದೆಯ ಬಿರಿಯ ಭಾವ ಬೀಸಿ,
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!

ನೂರು ಮತದ ಹೊಟ್ಟ ತೂರಿ, ಎಲ್ಲ ತತ್ವದೆಲ್ಲೆ ಮೀರಿ,
ನಿರ್ದಿಗಂತವಾಗಿ ಏರಿ,
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!

ಎಲ್ಲಿಯೂ ನಿಲ್ಲದಿರು, ಮನೆಯನೆಂದು ಕಟ್ಟದಿರು,
ಕೊನೆಯನೆಂದು ಮುಟ್ಟದಿರು,
ಓ ಅನಂತವಾಗಿರು
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!

ಅನಂತ ತಾನ್ ಅನಂತವಾಗಿ, ಆಗುತಿಹನೆ ನಿತ್ಯ ಯೋಗಿ,
ಅನಂತ ನೀ ಅನಂತ ವಾಗು, ಆಗು ಆಗು ಆಗು,
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!


ಕನ್ನಡ ಕವಿ ,ರಸ್ಟ್ರ-ಕವಿ-ಕುವೆಂಪು

Tuesday, February 23, 2010

ವಿಜಯನಗರದ ವೀರ ಪುತ್ರ

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಆಪರ ಕೀತಿಯೆ.........

ಮಾತೆ ತುನ್ಗಭಡ್ರೆ.. ಹರಿಯುತಿಹಲು ಇಲ್ಲಿ
ಮನವನ ಪಪವನು ತೊಳೆವ ಕಲ್ಲ್ಪವಲ್ಲಿ
ಮನವನ ಪಪವನು ತೊಳೆವ ಕಲ್ಲ್ಪವಲ್ಲಿ

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಡೆವ ವಿರುಪಕ್ಶ ಈವ ನಮಗೆ ರಕ್ಶೆ
ಜೀವಿಎ ತ ನಿಡುವನು ದರ್ಮದ ಡೀಕ್ಶೆ.....
ಜೀವಿಎ ತ ನಿಡುವನು ದರ್ಮದ ಡೀಕ್ಶೆ.....

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಕಡಿದು ಸುಟ್ಟಮುಟ್ಟಲಿತ ಗನ್ಡರನ್ಯ
ಹಕಿಸಿದನು ವಿಜ್ಯನಗರದ ವಿಡ್ಯರನಯ
ಹಕ್ಕಬುಕ್ಕರಲಿ ಭವಯತೆಯನು ತಾಲಿ
ದಿಕ್ಕು ದಿಕ್ಕು ಶನ್ತಿ ಸುಖದ ಕಹಲೆಯ ತೆಲಿ

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

Wednesday, February 3, 2010

shopping card



1)index.php
<?php

// Include database connection

require_once('inc/conection.php');

// Include functions

require_once('inc/functions.inc.php');

// Start the session

session_start();

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>PHP Shopping Cart Demo · Bookshop</title>

<link rel="stylesheet" href="css/styles.css" />

</head>



<body>



<div id="shoppingcart">



<h1>Your Shopping Cart</h1>



<?php

echo writeShoppingCart();

?>



</div>



<div id="booklist">



<h1>Books In Our Store</h1>



<?php

$sql = 'SELECT * FROM books ORDER BY id';

$result = $db->query($sql);

$output[] = '<ul>';

while ($row = $result->fetch()) {

$output[] = '<li>"'.$row['title'].'" by '.$row['author'].': £'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>';

}

$output[] = '</ul>';

echo join('',$output);

?>



</div>



</body>

</html>

2)cart.php
<?php

// Include database connection

require_once('inc/conection.php');

// Include functions

require_once('inc/functions.inc.php');

// Start the session

session_start();

// Process actions

$cart = $_SESSION['cart'];

$action = $_GET['action'];

switch ($action) {

case 'add':

if ($cart) {

$cart .= ','.$_GET['id'];

} else {

$cart = $_GET['id'];

}
echo '<script type="text/javascript">
<!--
window.location = "cart.php"
//-->
</script>
';
break;

case 'delete':

if ($cart) {

$items = explode(',',$cart);

$newcart = '';

foreach ($items as $item) {

if ($_GET['id'] != $item) {

if ($newcart != '') {

$newcart .= ','.$item;

} else {

$newcart = $item;

}

}

}

$cart = $newcart;

}

break;

case 'update':

if ($cart) {

$newcart = '';

foreach ($_POST as $key=>$value) {

if (stristr($key,'qty')) {

$id = str_replace('qty','',$key);

$items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart);

$newcart = '';

foreach ($items as $item) {

if ($id != $item) {

if ($newcart != '') {

$newcart .= ','.$item;

} else {

$newcart = $item;

}

}

}

for ($i=1;$i<=$value;$i++) {

if ($newcart != '') {

$newcart .= ','.$id;

} else {

$newcart = $id;

}

}

}

}

}

$cart = $newcart;

break;

}

$_SESSION['cart'] = $cart;

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>PHP Shopping Cart Demo · Cart</title>

<link rel="stylesheet" href="css/styles.css" />

</head>



<body>



<div id="shoppingcart">



<h1>Your Shopping Cart</h1>



<?php

echo writeShoppingCart();

?>



</div>



<div id="contents">



<h1>Please check quantities...</h1>



<?php

echo showCart();

?>



<p><a href="index.php">Back to bookshop...</a></p>



</div>



</body>

</html>

3)funtion.inc.php


<?php

function writeShoppingCart() {

$cart = $_SESSION['cart'];

if (!$cart) {

return '<p>You have no items in your shopping cart</p>';

} else {

// Parse the cart session variable

$items = explode(',',$cart);

$s = (count($items) > 1) ? 's':'';

return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>';

}

}



function showCart() {

global $db;

$cart = $_SESSION['cart'];

if ($cart) {

$items = explode(',',$cart);

$contents = array();

foreach ($items as $item) {

$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;

}

$output[] = '<form action="cart.php?action=update" method="post" id="cart">';

$output[] = '<table>';

foreach ($contents as $id=>$qty) {

$sql = 'SELECT * FROM books WHERE id = '.$id;

$result = $db->query($sql);

$row = $result->fetch();

extract($row);

$output[] = '<tr>';

$output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>';

$output[] = '<td>'.$title.' by '.$author.'</td>';

$output[] = '<td>£'.$price.'</td>';

$output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';

$output[] = '<td>£'.($price * $qty).'</td>';

$total += $price * $qty;

$output[] = '</tr>';

}

$output[] = '</table>';

$output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>';

$output[] = '<div><button type="submit">Update cart</button></div>';

$output[] = '</form>';

} else {

$output[] = '<p>You shopping cart is empty.</p>';

}

return join('',$output);

}

?>

4)connection.php

<?php

session_start();
$conn=mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("cart",$conn) or die(mysql_error());
?>





create cart.sql file and paste this code

//start

-- phpMyAdmin SQL Dump
-- version 2.11.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 07, 2010 at 08:39 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `cart`
--

-- --------------------------------------------------------

--
-- Table structure for table `books`
--

CREATE TABLE IF NOT EXISTS `books` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(30) NOT NULL,
`author` varchar(30) NOT NULL,
`price` float(10,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `books`
--

INSERT INTO `books` (`id`, `title`, `author`, `price`) VALUES
(1, 'five point some one', 'Chethan Bhagth', 400.00);


//end


import to phpmyadmin