Wednesday, 6 January 2016

enable and disable while loop textbox and checkbox using javascript

<?php
$i=1;
while($i<6){ ?><form action="" name="formname_<?php  echo $i ?>" method="post">
<div>
<label for='name'>Name<span class='required'>(required)</span></label>
<input type='text' id='textname_<?php echo  $i ?>' disabled="disabled"  placeholder='your name here' required value='<?php echo $i ?>'/>
</div>
<script>
function codename_<?php echo $i ?>() {

if(document.formname_<?php echo $i ?>.checkboxname_<?php echo  $i ?>.checked)
{
document.formname_<?php echo $i ?>.textname_<?php echo $i ?>.disabled=false;
}
else
{
document.formname_<?php echo $i ?>.textname_<?php echo $i ?>.disabled=true;
}
}</script>
<div style="width:70px; margin: 0 auto;">
<span >Edit</span> <input type="checkbox"   name="checkboxname_<?php echo  $i ?>"    onClick="codename_<?php echo $i ?>();" ></div>
</form><?php $i++; } ?>

Monday, 23 November 2015

Automatically Delay to open pop up


<style type="text/css">
.hide{
    display:none;
}
.clo {
   background:url(images/wrong_icon.png) no-repeat;
    display: block;
    height: 42px;
    position: absolute;
    right: -17px;
    top: 0;
    width: 42px;
    z-index: 2147483647;
}

.show {
    background-color: white;
    border: 5px solid orange;
    display: block;
    left: 37%;
    padding: 13px;
    position: absolute;
    top: 26%;
    width: 25%;
}


.image {
 display: inline;
    width: 35%;
}
form{
    clear: both;
    margin: 0 auto;
    padding: 10px 0;
    width: 70%;
   
}
</style>


<script type="text/javascript" language="javascript">

window.onload=function() 
{
setTimeout(func1, 2000);  //sets a timer which calls function func1 after 2,000 milliseconds = 2 secs.
   
};
function func1()
{
document.getElementById("my_div").className="show";
}
</script>



<div>main page</div>
<div id="my_div" class="hide">
<a href="#" class="clo" onclick="document.getElementById('my_div').style.display='none';"></a>
 <h3>Subscribe</h3>
     <div class="image" ><img src="images/email.png"></div>
      <div style="display: inline-block;width: 65%;">Subscribe to our newsletter to get the latest scoop right to your inbox.</div>
    <form action="#" method="post">
      <input type="email" name="email" class="subscribe-input" placeholder="Email address" autofocus>
      <button type="submit" class="subscribe-submit">Subscribe</button>
    </form>
 <p style="text-align:center;">
 &copy; 2014&ndash;2015 <a href="https://fawzulhameed.wordpress.com/" target="_blank">Fawzulhameed</a>
 </p>
</div>





Wednesday, 9 September 2015

Hidden feild validation using javascript and hide and show radio button based

<form name="form"  action="" method="post">
<input   type='radio'  value="rawmaterial" name='material'  class="dynamic_class">Transfer
    <input   type='radio'  value="salaryaccount" name='material'  class="dynamic_class">cheque
   
    <div id="tran">
<div class="form-group input-group">
 <span class="input-group-addon">transfer id</span>
    <input type="text" name="transfer_id" id="transfer_id" class="form-control"> </div> </div>
   
    <div id="transs">
   <div class="form-group input-group">
 <span class="input-group-addon">cheque number</span>
    <input type="text" name="cheque_no" id="cheque_no" class="form-control">  </div> </div>
     <button type='submit' name="submit" onclick="validate(event, this.form);" value="validate">submit</button>
    </form>
   
   
   <script>function validate(e, form) {
     
         var material = form.querySelectorAll('input[name="material"]:checked');
          var transfer_id=document.forms["form"]["transfer_id"].value
         var cheque_no=document.forms["form"]["cheque_no"].value
      
  if (!material.length ) {
        alert('please select fundsource or material source');
        e.preventDefault();
        return false;
    }
   
    if (form.material[0].checked != '' && !transfer_id.length ) {
        alert('please select transfer_id');
        e.preventDefault();
        return false;
    }
   
    if (form.material[1].checked != '' && !cheque_no.length)
   
      { alert('please select cheque no');
        e.preventDefault();
        return false;
    }
   

}</script>
<style> #tran{ display: none; }#transs{ display: none; }</style>
<script src="http://code.jquery.com/jquery.js"></script>
 <script>
 $(function(){
        $(".dynamic_class").click(function(){
          if($(this).val() === "rawmaterial")
            $("#tran").show("fast");

         if($(this).val() === "salaryaccount")
            $("#transs").show("fast");
             if($(this).val() === "rawmaterial")
             $("#transs").hide("fast");
              if($(this).val() === "salaryaccount")
             $("#tran").hide("fast");
           
           
        });
      });</script>

demo:
       
Transfer cheque
transfer id
cheque number

Monday, 24 August 2015

dropdown list height limit using javascript

<div class="form-group input-group">

   <span class="input-group-addon"  style="padding: 9px;"> Select a order no</span>
 <select name='order' class="form-control" onmousedown="if(this.options.length>5){this.size=4;}" onchange="this.size=0;" onblur="this.size=0;"
  style="padding: 3px;
    position: absolute;
    width: 160px;">
 <option value='1' >1</option>
<option value='2' >2</option>
<option value='3' >3</option>
<option value='4' >4</option>
<option value='5' >5</option>
<option value='6' >6</option>
<option value='7' >7</option>
<option value='8' >8</option>  </select>

demo:

Select a order no

send html, php email with all attachement like pdf,image...

    <?php
    function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
    $file = $path.$filename;
    $file_size = filesize($file);
    $handle = fopen($file, "r");
    $content = fread($handle, $file_size);
    fclose($handle);
    $content = chunk_split(base64_encode($content));
    $uid = md5(uniqid(time()));
    $name = basename($file);
    $header = "From: ".$from_name." <".$from_mail.">\r\n";
    $header .= "Reply-To: ".$replyto."\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
    $header .= "This is a multi-part message in MIME format.\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-type:text/html; charset=iso-8859-1\r\n";
    $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $header .= $message."\r\n\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
    $header .= "Content-Transfer-Encoding: base64\r\n";
    $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
    $header .= $content."\r\n\r\n";
    $header .= "--".$uid."--";
    if (mail($mailto, $subject, "", $header)) {
    echo "mail send ... OK"; // or use booleans here
    } else {
    echo "mail send ... ERROR!";
    }
    }

    $my_file = "1418109533.pdf";
    $my_path = $_SERVER['DOCUMENT_ROOT']."/shirdibaba/images/";
    $my_name = "Olaf Lederer";
    $my_mail = "my@mail.com";
    $my_replyto = "my_reply_to@mail.net";
    $my_subject = "This is a mail with attachment.";
    $my_message = "Hallo,\r\ndo you like this script? <h2>I hope it will help.</h2>\r\n\r\ngr. Olaf";
    mail_attachment($my_file, $my_path, "mhsatham8@gmail.com", $my_mail, $my_name, $my_replyto, $my_subject, $my_message);
    ?>
    

Wednesday, 12 August 2015

datepicker date to date based on from date

<label for="from">From</label>
<input type="text" id="from" name="from" />
<label for="to">to</label>
<input type="text" id="to" name="to" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function () {
    $("#from").datepicker({
  maxDate:+0,
   changeMonth: true,
   dateFormat: 'dd/mm/y',
   numberOfMonths: 1,
        onClose: function (selectedDate) {
            $("#to").datepicker("option", "minDate", selectedDate);
 
        }
    });
    $("#to").datepicker({
  maxDate:+0,
        changeMonth: true,
  dateFormat: 'dd/mm/y',
        numberOfMonths: 1,
        onClose: function (selectedDate) {
        }
    });
});</script>

Demo:





 

Thursday, 16 October 2014

onkeyup javascript same text feild operation like sum ,sub,multiple,division

<div>
 
   <label>
                    <span>current weight per bag</span>
                    <input  type="text"  name="cwpbags" id="nos" onKeyUp="sum1();"   autofocus>
                    <script> function sum1() {
            var txtFirstNumberValue = document.getElementById('nos').value;
          
             var txtthirdNumberValue = document.getElementById('bag').value;
              var txtthirddNumberValue = document.getElementById('loading').value;
             var initial =1000;
            var result = parseFloat(txtFirstNumberValue)  * parseFloat(txtthirdNumberValue) * parseFloat(txtthirddNumberValue) ;
            var div = parseFloat(txtFirstNumberValue)  * parseFloat(txtthirdNumberValue) / initial;
            if (!isNaN(result)) {
                document.getElementById('amount').value = result;
            };
            if (!isNaN(div)) {
                document.getElementById('freight').value = div;
            };
        }</script>
                </label>
               
                <label>
                    <span>current No of bag</span>
                    <input  type="text"  name="cnofbags" id="bag"  onkeyup="sum1();"  autofocus>
                </label>
            </div>
            <div>
                <label>
                    <span>loading</span>
                    <input  type="text"  name="loading" id="loading"  onKeyUp="sum1();"  autofocus>
                </label>
            </div><div>
                <label>
                    <span>amount</span>
                    <input  type="text"  name="amount" id="amount"  required autofocus>
                </label>
            </div>
            <div>
                <label>
                    <span>HOW many tons</span>
                    <input  type="text"  name="loading" id="freight"   autofocus>
                </label>
            </div>
DEMO:

Wednesday, 1 October 2014

second Highest value get database

SELECT totalprice FROM raw_arrivepurchase WHERE totalprice = (SELECT MAX(totalprice) FROM raw_arrivepurchase WHERE totalprice < (SELECT MAX(totalprice) FROM raw_arrivepurchase))

Monday, 22 September 2014

Automatic Logout after 15 minutes of inactive

<?php
     session_start
();
     
$_SESSION['session_time'] = time(); //got the login time for user in second
     
$session_logout = 900; //it means 15 minutes.
     //and then cek the time session
    
if($session_logout >= $_SESSION('session_time']){
        
//user session time is up
       //destroy the session
      
session_destroy();
     
//redirect to login page
     
header("Location:the-path-your-login-page.php");
    }
?>



















 

Saturday, 13 September 2014

multiple textbox if click the button database based

multiple textbox if click the button database based

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Add input</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
function addInput(f) {
var aInputs=f.getElementsByTagName('input');
for(var i=0; i<aInputs.length; i++) {
    if(aInputs[i].className=='hide') {
        aInputs[i].className='';
        break;
        }
    }
}
</script>

<style type="text/css">
input {display:block;}
.hide {display:none;}
</style>

</head>
<body>
<form action="#" name="form1">
<div>
<input type="text" name="txt1">
<input class="hide" type="text" name="product1">
<input class="hide" type="text" name="product2">
<input class="hide" type="text" name="product3">
<input class="hide" type="text" name="product4">
<button type="button" onclick="addInput(this.form);">plus</button>
</div>
</form>
</body>
</html>

demo: Add input

Saturday, 30 August 2014

Add two textbox values and display the sum in a third textbox automatically

<div>  
                <label>
                    <span>price</span>
                    <input placeholder="price" type="text" name="price" id="pri" onkeyup="sum();" required>
                </label>
               <script> function sum() {
            var txtFirstNumberValue = document.getElementById('pri').value;
            var txtSecondNumberValue = document.getElementById('load').value;
            var result = parseFloat(txtFirstNumberValue) + parseFloat(txtSecondNumberValue);
            if (!isNaN(result)) {
                document.getElementById('total').value = result;
            }
        }</script>
            </div>
             <div>
                <label>
                    <span>loading charge</span>
                    <input placeholder="loading" type="text" name="loading" id="load" onkeyup="sum();"  required>
                </label>
            </div>           
              <div>
                <label>
                    <span>Total Price</span>
                    <input placeholder="loading" type="text" name="loading" id="total"  required>
                </label>
            </div>


Demo:


Monday, 25 August 2014

jQuery Get input Text value and set Value

<html>
<head>
<title>example</title>

<link
 href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
 rel="stylesheet" type="text/css" />

<script
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"
 type="text/javascript"></script>
<script
 src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
 type="text/javascript"></script>
<script type="text/javascript">
        $(document).ready(function() {
            $('#myInputText').keyup(function() {
             $('#myOutputText').val($(this).val());
             $('#myDIVTag').html('<b>' + $(this).val() + '</b>');
            });
        });   
    </script>
</head>
<body>

  <form id="myForm" action="">
   <fieldset>
    <legend>jQuery Get and Set input Text value</legend>

    <p>
     <label for="myInputText">
      Type something here:
     </label>
 
     <input
     id="myInputText" type="text" name="inputBox" />
    </p>
    <p>
     <label for="myOutputText">
      See Result in this Text Box:
     </label>
 
     <input
     id="myOutputText" type="text" name="outputBox"
      readonly="readonly" />
    </p>
    <p>
     See Result in this DIV section:
    </p>
     <div id="myDIVTag"></div>
   </fieldset>
  </form>
 </div>
</body>
</html>

Demo:
example
jQuery Get and Set input Text value

See Result in this DIV section:

Dispaly value of one textbox to another textbox using Jquery & Javascript

Dispaly value of one textbox to another textbox using Jquery & Javascript

 <script>
function copyText2() {
txtHint = document.getElementById("txtHint");
color = document.getElementById("color");
color.value = txtHint.value;
}
</script>
<div>
TextBox 1 : <input type="text" id="txtHint" onkeyUp="copyText2()"></input>
TextBox 2 : <input type="text" id="color"></input>
</div>
</html>

Demo:

 
TextBox 1 : TextBox 2 :

Thursday, 21 August 2014

HTML: Fixed Size , Resizable Text Area and character limit.

Text Area are mostly used for data entry in web forms. They could be resizable on run-time and can also be created with fixed size having particular width and height.


Resizable Text Area:

Below I am showing a Resizable text area and its respective code which I have used to create it.

Below is the html code that has been used to create Resizable text area.


<textarea style="height: 134px; width: 296px;">Resizable Text Area</textarea>


Fixed Size Text Area & character limit fixed:

Now next I am going to show an example of fixed size Text Area.


Here is the html source used to create Fixed Size Text Area:

<textarea style="height: 134px; resize: none; width: 296px;" maxlength="50">Fixed Size Text Area</textarea>

Wednesday, 20 August 2014

Button click to send email in php

<form action="" method="post">
    <input type="submit" value="Send details to...." />
    <input type="hidden" name="button_pressed" value="Email" />
</form>

<?php

if(isset($_POST['button_pressed']))
{
    $to      = 'who@example.com';
    $subject = 'subject Message';
    $message = 'All is well';
    $headers = 'From: fhfh@example.com' . "\r\n" .
        'Reply-To: fhfh@example.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
$headers .= 'Cc: myham@example.com' . "\r\n"; 
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 

    mail($to, $subject, $message, $headers);

    echo 'Email Sent.';
}

?>

Tuesday, 19 August 2014

.ht access ( extension remove )

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
-------------------------------------------------------------------
#To remove PHP pages extension just copy the below 4 lines of code and past into your htaccess.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
-----------------------------------------------------------------
#index remove:

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
------------------------------------------------------------
#404 page create

ErrorDocument 404 http://molasses.co.in/404.html
-------------------------------------------------------------
#canonical link enable:

<link rel="canonical" href="http://www.fawzulhameed.com/" />
RewriteEngine on

RewriteCond %{HTTP_HOST} ^fawzulhameed.com$
RewriteRule ^(.*)$ http://www.^fawzulhameed.com/$1 [R=301,L]