Posts

Showing posts from October, 2013

How to put images in HTML text and password fields?

How to put images in HTML text and password fields? You can easily place images inside text fields in HTML. To explain this, I am making a registration form in  which I have text and password fields like name, email, password and confirm password. I want to put user image  inside name text field, email image inside email field and so on. I have kept images(32*32 png icons) of user, email and password  in images folder. HTML file <form action="register.php" name="register" id="register" method="post">         <input type="text" name="name" id="name" placeholder="Your name" autocomplete="off" tabindex="1" class="txtinput">   <input type="email" name="email" id="email" placeholder="Your e-mail address" autocomplete="off" tabindex="3" class="txtinput">   <input type="password" n

How to make stylish Submit and Reset HTML buttons with CSS3?

How to make stylish Submit and Reset HTML buttons with CSS3? Recently, I had to create a registration form which had submit and reset buttons. I wrote some CSS3 code to  look submit and reset html buttons stylish. I thought of sharing this code with all you guys so that it might  help someone. If you have any better CSS tips to make these submit and reset buttons more stylish, do share it. My HTML file: <div id="buttons">     <input type="reset" name="reset" id="resetbtn" class="resetbtn" value="Reset">     <input type="submit" name="submit" id="submitbtn" class="submitbtn" value="Register"> </div> My CSS file: #buttons  {    display: block; padding-top: 10px;  } #buttons #resetbtn  {   display: block;   float: left;   color: #515151;   text-shadow: -1px 1px 0px #fff;   margin-right: 20px;   height: 3em;   padding: 0 1em;   outline: 0;   font-weight: bol

How to pause javascript setInterval method for sometime and restart again?

How to pause javascript setInterval method for sometime and restart again? I was using javascript setInterval method to display different divs after a regular interval of time. In between, I fell into the requirement of pausing the javascript setInterval method for sometime, do some stuff and restart it again. So, I repeatedly used setInterval and clearInterval to acheive my functionality.  I have 3 divs: div0 (green), div1 (yellow), div2 (red). All are overlapping each other. I am using setInterval to hide and show div1 and div2 after every second. if index = 4 or 6, I am showing red div else yellow div.  My requirement is that, When index becomes 8, I want to pause the setInterval for 5 seconds and till then show div0 (green) and afterwards resume the loop of setInterval until clearInterval is called. Below is the code snippet for pausing and restarting setInterval method which is self explanatory. <!DOCTYPE html> <html lang="en">   <head>     <title>

How to show / hide images randomly at regular intervals in javascript by shuffling the array?

How to show / hide images randomly at regular intervals in javascript by shuffling the array? I had one requirement in one of my projects that I had an image which I had to show randomly in 4 places (div) in my webpage at regular intervals using javascript. I had asked this problem in stackoverflow . I got good help from a guy named "Hiral" there. With his/her help, I was able to implement this functionality. For implementing my functionality, I am shuffling an array and using javascript setInterval() and clearInterval() methods. Let me explain you my requirement and solution. Maybe you encounter similar requirement in future, then it might be helpful to you! I have following 4 divs (bulb1, bulb2, bulb3, bulb4) and the image bulb.png in images folder of my project. <div id="bulb1" class="lightbulb"><img src=".\images\bulb.png" /></div> <div id="bulb2" class="lightbulb"><img src=".\images\bulb

How to implement javascript count down timer using setInterval and clearInterval methods?

How to implement javascript count down timer using setInterval and clearInterval methods? I had to implement  a count down timer in my project which runs for 40 seconds. I implemented count down timer in javascript using setInterval() and clearInterval() methods. I am sharing my javascript timer code in this post. It is very simple and can be understood in one go. Below is my javascript code snippet for count down timer.         function playTimer()         { var count= 40; document.getElementById("timer").innerHTML=count + " secs left"; var count_down=setInterval(timer, 1000);  } function timer() { count=count-1; //if time is finished if (count <= 0) { document.getElementById("timer").innerHTML="Time Over"; clearInterval(count_down);                         //call you function which has to be called after timer return; } //if 1 second is left, display "sec&quo

How to use setInterval and clearInterval jQuery methods in PHP?

How to use setInterval and clearInterval jQuery methods in PHP? I will explain usage of setInterval and clearInterval jQuery methods with the help of simple example in PHP. Suppose there is a PHP array in which there are 3 elements. I want to display all of them one by one at regular intervals and stop when all the three array elements have been displayed. I will use setInterval and clearInterval jQuery methods here to implement it. Here is my index.php file <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> var count = 0; $(document).ready(function(){ var auto_refresh = setInterval(function (){     $('#mydiv').load('myphpfile.php', {count: count}, function () {         count = count + 1;         //after three attempts it won't call php file.         if (count > 2) {             clearInterval(auto_refresh);         }     }).fadeIn(&quo

How to generate Random Numbers at Regular Intervals in PHP?

How to generate Random Numbers at Regular Intervals in PHP?  Following is the simple PHP tutorial to demonstrate how to generate random numbers at regular intervals in PHP? I will use jquery setInterval() method for calling PHP file (which generates random numbers) at regular intervals say after every second in my example. I will use PHP rand() function to generate random numbers in PHP. I am using google CDN for jquery libraray. So here is the simple example in PHP to generate random numbers at regular intervals. index.php file <!DOCTYPE html> <html lang="en"> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var auto_refresh_random_numbers = setInterval( function () { $('#load_random_numbers').load('generate_random_numbers.php').fadeIn("slow"); }, 1000); // refresh random numbers after ever

125 Basic C# Interview Questions and Answers

125 Basic C# Interview Questions and Answers Below is the list of 125 basic C# interview questions with their answers. These C# interview questions and answers are very simple and straight-forward which cover the basic concepts of C# mostly related to object oriented concepts. So if you are preparing for C# interview, I will suggest you to must go through these 125 C# basic interview questions and answers to revise your C# concepts. Here goes the list of 125 basic C# interview questions and answers. 1. What is C#?   C# (pronounced "C sharp") is a simple, modern, object-oriented, and type-safe programming language. It will immediately be familiar  to C and C++ programmers. C# combines the high productivity of Rapid Application Development (RAD) languages. 2. What are the types of comment in C#?   There are 3 types of comments in C#. Single line (//) Multi (/* */) Page/XML Comments (///). 3. What are the namespaces used in C#.NET?   Namespace is a logical grouping of class.