Tuesday, November 22, 2011

How to Calculate sum of number onchange event.

function sumIt(theName) {
theName = theName.substr(0,theName.length-1)
var f = document.forms["myForm"]
var s = 0
for (var i=1;i<=4;i++) {
var v = f.elements[theName+i].value
v = parseFloat(v)
if (isNaN(v)) continue
v = Math.abs(v)
f.elements[theName + "total"].value = s

<form name="myForm">
one: <input type=text name="Val1" onchange="sumIt(this.name)">
two: <input type=text name="Val2" onchange="sumIt(this.name)">
three: <input type=text name="Val3" onchange="sumIt(this.name)">
four; <input type=text name="Val4" onchange="sumIt(this.name)">
Suma:<input type="text" READONLY class="disabled" name="Valtotal" size="20" value="0.00">

Friday, November 11, 2011

how to Auto-Login in wordpress

//determine WordPress user account to impersonate
$user_login = 'guest';

//get user's ID
$user = get_userdatabylogin($user_login);
$user_id = $user->ID;
wp_set_current_user($user_id, $user_login);
do_action('wp_login', $user_login);
<script type="text/javascript">
window.location = "wp-admin/profile.php";

Tuesday, November 8, 2011

Multiple Images upload in php

<form action="" method="post" enctype="multipart/form-data">
<p>Three Files:
<input type="file" name="myfile[]" />
<input type="file" name="myfile[]" />
<input type="file" name="myfile[]" />
<input type="submit" value="Send" />
    foreach ($_FILES["myfile"]["error"] as $key => $error) {
      if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["myfile"]["tmp_name"][$key];
        $name = $_FILES["myfile"]["name"][$key];
        move_uploaded_file($tmp_name, "data/$name");
rathoddhirendra.blogspot.com-Google pagerank and Worth