Monday 22 April 2013

Add new field on click in forms


<?php
if(isset($_POST['sub']))
{
echo "<pre>";
print_r($_POST);
echo "</pre>";
}
?>
<html>
<head>
<style>
p{overflow:visible; }

</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
function appendText()
{

var txt3=document.createElement("p");
txt3.innerHTML="<input type='text' name='file[]'  />";               // Create text with DOM
$("div").append(txt3);        // Append new elements
}
</script>
</head>




<body>
<button onclick="appendText()">Append text</button>
<p>Add files here.</p>
<form action="" method="post" name="form1" >


<div></div>
<input type="submit" name="sub" />
</form>
</body>
</html>

Friday 12 April 2013

make active link highlight

HI with the use of jquery we can easily do this





<html>
<head></head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function () {
$(".somelink a").click(function (e) {
e.preventDefault();
$(".somelink a").addClass("active").not(this).removeClass("active");
});
});
</script>
<style>
.active { color:red;}
</style>
</head>
<body>
<ul class="somelink">
<li><a href="#">Sample Anchor</a></li>
<li><a href="#">Sample Anchor</a></li>
</ul>
</body>
</html>

enjoy this ...........