...

Hi! I’m Starx

experienced Software Developer. And this is my blog
Start Reading About me
Blog Page
March 23, 2012

Jquery SetTimeout issue (I know posts already exists…)

Question by Marc

I have a table with one column and four rows. Each tr has a class called ‘ligne’. I also have a button. When clicked, I would like to run a each loop on the class ‘ligne’. For each item I would like to give a blue background, but after sleeping for 1 second. I read a lot of posts, applied what i read, but it is not working. Hope someone can help me understand. Cheers. Marc

http://jsfiddle.net/M2ZCh/

my html:

<table>
  <tr class="ligne">
    <td>one</td>
  </tr>
  <tr class="ligne">
    <td>two</td>
  </tr>
  <tr class="ligne">
    <td>three</td>
  </tr>
  <tr class="ligne">
    <td>four</td>
 </tr>
</table>

<input id="btn-timeout" type="submit" value="timeout!"/>

my js:

$(document).on({
    click: function() {

        $(".ligne").each(function() {

            setTimeout(function() {

                $(this).css('background', 'blue');

            }, 1000);

        });


    }

}, "#btn-timeout");​

Answer by Tim Medora

Here’s a version which highlights each cell one by one: http://jsfiddle.net/M2ZCh/9/

$(document).on({
    click: function() {
        var index = 0;
        $(".ligne").each(function() {
            var obj = $(this); // pin reference to element

            setTimeout(function() {
                obj.css('background', 'blue');
            }, 1000 * ++index);
        });
    }
}, "#btn-timeout");​

Answer by Starx

You can do this, as this

$("#btn-timeout").click(function() {
    window.setTimeout(function () {
       $(".ligne").css("background","blue");
    }, 1000);
});

Demo

Update:

If you want each boxes to changed background consequently then, you have to use setInterval() instead.

var tlenth = $(".ligne").length;
$("#btn-timeout").click(function() {
    var i = 0;
    var int = setInterval(function () {
       $(".ligne").eq(i).css("background","blue");
        i++;
        if(i>tlenth-1) { clearInterval(int); }
    }, 1000);
});

Demo

Read more

How to check if form field is empty using PHP

Question by Lap Ming Lee

I am trying to check if the field is empty. If it is, redirect to sign uppage. Right now, it just keeps on creating multiple account with NULL username and password. I tried using strlen(), but it doesn’t seem to be working.

<?php
        try{
        $username = trim($_POST['username']);
        $password = trim($_POST['password']);
        $hash = crypt($password_signup, '$3a$08$2'); // salt 

        $connection = new PDO ('mysql:host=localhost;dbname=tongue', 'web', 'lapming1');
        $connection -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $connection -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

        require_once("functions.php");

        $sql = 'SELECT email, hash FROM user WHERE email=:username';
        $row = login ($sql, $connection, $username_signup);

        if ($username = false){
            header("Location: sign_up.php?error");
        };

        if ($row) {
            header("Location: sign_up.php?msg=1");
        }
        else {
            $sql = 'INSERT INTO user(email, hash) VALUES (:username, :password)';
            create($sql, $connection, $username_signup, $password_signup);
            header("Location: index.php");
        };


    $connection = null;

    } catch(PDOException $e) {
        echo $e->getMessage();
    }

?>

Answer by Baba

I can see the error .. you are using basic assignment operator “=” insted of Comparison operators “==”

Change

   if ($username = false){
        header("Location: sign_up.php?error");
    };

To

   if ($username == false){
        header("Location: sign_up.php?error");
    };

Or Better Approach

  if (empty($username){
        header("Location: sign_up.php?error");
    };

Thanks
🙂

Answer by Starx

Its easier this way

if (!strlen($username)){
 header("Location: sign_up.php?error");
};

And you are not using correct comparison operators

$username = false assigns the boolean value false to $username and will always be returned as true, and thus the header will keep on being sent.

Read more

Convert timezone in php

Question by Nishu

I have these timezones. I want to get the current datetime depends on the given timezone. The user will select either one timezone. so need to return current time.

ASKT
CDT
EDT
HST
MDT
MST
PDT

How can i convert? Please help

Answer by Starx

Use the DateTime Class

$time = time(); //Get the current time
$date = new DateTime($time, new DateTimeZone('Pacific/Nauru')); //Set a time zone
echo $date->format('Y-m-d H:i:sP') . "n"; //display date

$date->setTimezone(new DateTimeZone('Europe/London')); //set another timezone
echo $date->format('Y-m-d H:i:sP') . "n"; //display data again

This, way you don’t have to give the same timestamp as new argument every time like mishu’s answer.

Read more

How to disable one radio input from radio group?

Question by IT ppl

How can i disable the one radio input from the radio group ?

<input type="radio" name="radiogrp" value="op1" checked="checked">Option1
<input type="radio" name="radiogrp" value="op2"> Option2
<input type="radio" name="radiogrp" value="op3" > Option3
<input type="radio" name="radiogrp" value="op4"> Option4

My question is i want to disable option1 after clicking on any other button

For example:

when i select option2, than option1 should be disabled

Answer by Jibi Abraham

Check this Fiddle I have just added

Let me know if this is not what you intended

As requested – posted fiddle answer

$('.rd').click(function(){
    $('.rd[value="op1"]').attr('disabled', 'disabled');       
});​

Answer by Starx

Its very easy, use jQuery’s attribute selector. Here is an example of disabling the radio button with value op3

$('input[value="op3"]').attr('disabled', 'disabled');

Demo


Here is your solution

var radios =  $('input[name=radiogrp]'); //Cache all the radio button
radios.click(function() { 
//Attach a fucntion to the click event of all radio button

    if(this.value!='op1') { //Check if currently click button has value of op1
        radios.filter('[value="op1"]').prop('disabled', true); //if not disable the first
    }
});

Demo

Read more

Basic Java concept

Question by vishesh

Hi I have following code block

public class Driver {

 static String x = "x";
 static String y = "y";

public static void main(String[] args) throws Exception {
         setX(x);
         System.out.println("but x is still "+x);           
}

 static void setX(String x){
      x="a";
      System.out.println("now x should be = "+x);         
  }
}

and this prints

now x should be = a
but x is still x

I was hoping to get

now x should be = a
but x is still a

I know there are ways to get what I want,but please answer why this does not work.

Answer by Jigar Joshi

static void setX(String x){
      //x="a"; //refers to local variable , from parameter
      //make it as follows
      Driver.x="a";
      System.out.println("now x should be = "+x);         
}

Answer by Starx

You have to use Driver.x to set the value. You cannot update the static variable with just defining x="a"

static void setX(String x){
    Driver.x="a";
    System.out.println("now x should be = "+Driver.x);    
}
Read more

How to make the DIV equivalent of colspan?

Question by Nick Rosencrantz

I want to implement this view
enter image description here

But I have one question: The text which says “Munstycke…” should not have the linebreak this far to the left, it should be like in the specification:
enter image description here

My code that achieves the view first mentioned is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">    
<html>
<head>
    <link href="css_js/styles.css" rel="stylesheet" type="text/css">
    <link href="css_js/positions.css" rel="stylesheet" type="text/css">
    <link href="css_js/floats.css" rel="stylesheet" type="text/css">
    <script src="css_js/sorttable.js"></script>
    <script language="JavaScript1.2" src="css_js/general_arendeprocess.js"></script>
    <script language="JavaScript1.2" type="text/javascript">
    function ingVar(x) { 
    var applicationDependence;
    applicationDependence = x;
    document.getElementById('ff').style.display='none';
    document.getElementById('avd').style.display='none';
    document.getElementById('utb').style.display='none';
    document.getElementById('oepa').style.display='none';
    document.getElementById('aooep').style.display='none';
    if (applicationDependence == 'ff'){ 
            document.getElementById('ob').style.display='none';
            document.getElementById('ff').style.display='';
            }
    if  (applicationDependence == 'avd'){
            document.getElementById('ob').style.display='none';
            document.getElementById('avd').style.display='';
            }
    if  (applicationDependence == 'utb'){
            document.getElementById('ob').style.display='none';
            document.getElementById('utb').style.display='';
            }       
    if  (applicationDependence == 'oepa'){
            document.getElementById('ob').style.display='none';
            document.getElementById('oepa').style.display='';
            }
    if  (applicationDependence == 'aooep'){
            document.getElementById('ob').style.display='none';
            document.getElementById('aooep').style.display='';
            }       
    if  (applicationDependence == 'ob'){
            document.getElementById('ob').style.display='';
            }       
    }
    </script>
    <title>Ingivningsdag - NAT. - Pandora </title>
</head>
<%
    final Logger logger = Logger.getLogger("arendeprocess_grunduppgifter.jsp");
    ArendeProcessPageController apc = new ArendeProcessPageController(request);
    GrunduppgifterPageController pc = new GrunduppgifterPageController(request);
    String arendeTyp = apc.getArendeTyp();
    boolean showSearch = false;
    AnsokanInfo ansokanInfo = apc.getAnsokanInfo();
    PersonInfo editPerson = new PersonInfo();
    if(ansokanInfo != null && ansokanInfo.hasEditPersonInfo()) {
        editPerson = ansokanInfo.getEditPersonInfo();
    } else {
        editPerson.setFornamn(apc.getNyregPerson().getFornamn());
        editPerson.setEfternamn(apc.getNyregPerson().getEfternamn());
        editPerson.setForetag(apc.getNyregPerson().getForetag());
        //editPerson.setOrgnr(apc.getNyregPerson().getOrgnr());
        editPerson.setLandKod(apc.getNyregPerson().getLandKod());
    }
    if(apc.getLatestAction().equals("Namnsokning") && apc.getLatestActionCommand().equals("search")) {
        showSearch = true;    
    }

%>

<body><form name="actionForm" action="PandoraActionServlet" style="display: inline;" method="post">
    <input type="hidden" name="currPage" value="<%=request.getRequestURI()%>" />
    <input type="hidden" name="action" value="" />
    <input type="hidden" name="actionCommand" value="" />
    <input type="hidden" name="actionModifier" value="" />
    <input type="hidden" name="actionTarget" value="" />
    <input type="hidden" name="destination" value="" />
    <input type="hidden" name="currIndex" value="" />


<!--sidinneh&aring;ll-->
<div class="form-bg">
<div class="data-bar">
<div class="yta2  TB_nb fontS80 ">
    <div class="clear ">&nbsp;</div>
    <div class="fr1 ">&nbsp;</div>
    <div class="fr5 "><input type="button" value="Historik"></div>
    <div class="fl30"><h2>Grunduppgifter</h2></div>
    <div class="clear quarter">&nbsp;</div>
</div>
</div>
<div class="data-bar">
<div class="clear "></div>

<div id="indag" class="yta2   TB_nb fontS80">
    <div class="clear half">&nbsp;</div>
    <div class="fl10"><h3>Ingivningsdag</h3></div>

    <div class="fl20">Ans&ouml;kans beroende:</div>
    <div class="fl20">Oberoende</div>
    <div class="fl10">&nbsp;</div>
    <div class="fl1">&nbsp;</div>
    <div class="fl20"></div>
    <div class="clear"></div>

    <div id="ob">
        <div class="fr10 smallg">F&ouml;rnamn Efternamn,<br>handl&auml;ggarkod<br><br></div>
        <div class="fl10"></div>
        <div id="datum" class="fl20">Datum ingivningsdag:</div>
        <div class="fl20">

        <strong>2009-01-01</strong>
    </div>
<div class="clear"></div>
    <div class="data-bar"></div><br>
    <div class="fl10"><h3>Sökande</h3></div>
    <div class="fl20"><div class="data-box">

    <table border="0">
        <tr><td>c o Andersson</td><td>Telefon</td><td>0707532637</td></tr>
        <tr><td>Angeredsgatan 12 B, 3 tr</td><td>Fax</td><td>7551444</td></tr>
        <tr><td>234 56 Angegerdet</td><td>E-post</td><td>0707532637</td></tr>
        <tr><td>Sverige</td><td>Referens</td><td></td></tr>
        </table>

    </div></div>

    <div class="clear"></div>

    <div class="fl10"><h3>Uppfinnare</h3></div>
    <div class="fl20"><div class="data-box">

    <table id="table" border="0">
        <tr><td>c o Andersson</td><td>Telefon</td><td>0707532637</td></tr>
        <tr><td>Angeredsgatan 12 B, 3 tr</td><td>Fax</td><td>7551444</td></tr>
        <tr><td>234 56 Angegerdet</td><td>E-post</td><td>0707532637</td></tr>
        <tr><td>Sverige</td><td>Referens</td><td></td></tr>
        </table>

    </div></div>


    <div class="clear"></div>

    <div class="fl10"><h3>Ombud sökande 1-2</h3></div>
    <div class="fl20"><div class="data-box">

    <table border="0">
        <tr><td>c o Andersson</td><td>Telefon</td><td>0707532637</td></tr>
        <tr><td>Angeredsgatan 12 B, 3 tr</td><td>Fax</td><td>7551444</td></tr>
        <tr><td>234 56 Angegerdet</td><td>E-post</td><td>0707532637</td></tr>
        <tr><td>Sverige</td><td>Referens</td><td></td></tr>
        </table>

    </div></div>

    <div class="clear"></div>
    <div class="data-bar"></div><div class="clear"></div><br>

    <div class="fl10"><h3>Benämning</h3><br>Uppfinningens benämning:</div>
    <div class="fl20">

    Munstycke och oftast ett mycket längre krångligt begrepp i en lång lång texststträng längre krångligt begrepp i en lång lång textsträng längre krängligt begrepp i en lång lång textsträng längre krånglig textsträng

    </div>

    <div class="clear"></div>

    <div class="fl10"><h3>Prioriteter</h3></div>
    <div class="fl20">

    <table border="0">
        <tr><td>Prioritet</td><td>Prioritetsdag</td><td>Prio. dok i ärende</td></tr>
        <tr><td>DK 0900231-1</td><td>2009-03-21</td><td>0800213-3</td></tr>
        <tr><td>EP 123234.3</td><td>2009-02-11</td><td>PCT/SE2002/000231</td></tr>
        <tr><td>SE PCT/SE2006/032131</td><td>2006-02-12</td><td></td></tr>
        </table>

    </div></div>

    <div class="clear"></div>

    <div class="fl10"><h3>Deposition mikroorganismer</h3></div>
    <div class="fl20">

    <table border="0">
        <tr><td>Depositionsmyndighet</td><td>Depositionsdatum</td><td>Depositionsnummer</td><td>Endast utlämning till expert</td></tr>
        <tr><td>Smittskyddsinstitutet</td><td>2009-03-21</td><td>11123</td><td>Nej</td></tr>

        </table>

    </div>

    <div class="clear"></div>

    <div class="fl10"><h3>Handläggare</h3></div>
    <div class="fl20">

    Markus Stålö, MSTÅ

    </div>

    <div class="clear"></div>

    <div class="fl10"><h3>Resultat</h3></div>
    <div class="fl20">

    <table border="0">
        <tr><td>c o Andersson</td><td>Telefon</td><td>0707532637</td></tr>
        <tr><td>Angeredsgatan 12 B, 3 tr</td><td>Fax</td><td>7551444</td></tr>
        <tr><td>234 56 Angegerdet</td><td>E-post</td><td>0707532637</td></tr>
        <tr><td>Sverige</td><td>Referens</td><td></td></tr>
        </table>

    </div>

</div><!-- indag -->

</div>

</div>
</div>
</form>
</body>
</html>


*  {font-family:arial;}

.avnamn{ 
                color: #90002b; 
                font-size: 140%; 
                display: inline; 
                vertical-align: 3%; 
                margin-left: 1%;
                }

.b{border:1px solid #000;}

.readonly{background-color: #CCC;}

.Webdings{
    font-family: Webdings;
    }

ul{margin-top: 0px}

.mt3{margin-top:-3px;}
.mt5p{margin-top:5px;}

.fontS80 {font-size: 80%;} 
a:link{color:#000; text-decoration:none; }
a:visited{color:#000; text-decoration:none; }
a:hover{color:#000; text-decoration:none; }
a:active{color:#000; text-decoration:none; }

.fontS75 {font-size: 75%;} 

.link{color: #003366;
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;}

.link_sm{color: #003366;
    text-decoration: underline;
    cursor: pointer;}

.link_sm{font-size: 70%;cursor: pointer;}

.small{font-size: 75%;}

.smallg{font-size: 75%;
color: #555;}

.ssmall{
    font-size: 65%;
    font-weight: bold;
    color: #555;
}
.small60{font-size: 60%;}
.small50{
    font-size: 50%;
    color: #333;
}
.smallb{font-size: 85%;}
table{display:inline;}

h1{font-size: 130%;display:inline;}
h2{font-size: 100%;display:inline;}
h3{
    font-size: 80%;
    display:inline;
    font-family: "Arial Unicode MS", Arial, Helvetica, sans-serif;
}
h4{font-size: 70%;display:inline;}
h5{
    font-size: 80%;
    display:inline;
    font-family: "Arial Unicode MS", Arial, Helvetica, sans-serif;
}

.hthin{
    font-size: 125%;
}

.th {text-align: left;}

td, th{font-size: 75%;
    vertical-align: text-top;}
.td_link{cursor: pointer;}
.td40{height:40px;}
.td60{height:60px;}



.thkant{
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    font-size: 70%;
        text-align: left;
}

.labb{F0F0E3; c1c1b3 }

.bb{border-bottom: 1px solid #000;}
.bbV{border-bottom: 1px solid #FFF;}
.TB_nbA {background-color:#CCC;}
.TB_bt, .TB_nb, .TB_db, .TB_bb {background-color:#efefdc;}

.hk {background-color:#d9ddb3;}

.hknot {background-color:#f9faf2;}
/*<!--F8F8F1-->*/
.TB_bt{border-top: 1px solid #FFF;}
.TB_bt5{border-top: 5px solid #FFF;}
.TB_bb{border-bottom: 1px solid #999;}
.TB_bb2{border-bottom: 2px solid #c1c1b3;}
.TB_db{border-bottom: 1px solid #000; border-top: 1px solid #000;}
.TB_tb{border-top: 2px solid #efefdc;}

.TB_bo{border: 2px solid #efefdc;}
.TB_bo_hk{border-top: 1px solid #efefdc;}


.TB_bo2{border: 1px solid #efefdc;}

.TB_bo2B{
border-top: 2px solid #c1c1b3;
border-left: 3px solid #efefdc;
border-right: 3px solid #efefdc;
border-bottom: 2px solid #c1c1b3;
}

.TD_bo{
    border-right: 1px solid #c1c1b3;
    width: 9%;
    font-size: 70%;
    text-align: center;
}

.TD_bo2{

    border-right: 0;
    width: 9%;
    font-size: 70%;
    text-align: center;
}

.ytb{
    border-left:3px solid #efefdc;
    border-right:3px solid #efefdc;
}

.datum {
    font-size: 70%;
    padding-right: 5px;
    vertical-align: text-top;} 
.sub {background:#EAEAEA;}
.sub_meny, .sub_meny_r, .sub_meny_active, .sub_meny_sm{
    font-size: 70%;
    padding-left: 20px;
    padding-right: 20px;
    vertical-align: text-top;}

.sub_meny_sm {
    font-size: 60%;
    vertical-align: middle;
    padding-left: 10px;
    padding-right: 10px;
}   

.sub_meny_r{
    float:right;
    font-size: 70%;
    padding-left: 8px;
    padding-right: 8px;}

.sub_meny_rm{margin-top:4px;}
.sub_meny_active{font-weight: bold;}

.flikkant1 {
    background-image: url(../images/fl1k.jpg);
    background-position: center;
    z-index: -1;}

.inl_namn{
    font-weight: bold;
    font-size: 70%;
    color: Black;
    text-decoration: none;}

.th{text-align: left;}
.tr{text-align: right;}

.g1{
    background-color: #FFF;
    line-height: 20px;
}

.g2{
    background-color: #EEE;
    line-height: 20px;
}

.g3{
    background-color: #DCDCDC;
    line-height: 20px;
    font-weight: bold;
    font-size: 100%;
}
.g4{
    background-color: #CCC;
    line-height: 20px;
}

.popup{
    border-color: #000; 
    border-style: groove; 
    border-width: 2px; 
    padding: 0px; 
    background-color: #FFF;
    font-size: 70%;
}

.popupN{
    background-color: #F0F0E3;
    color: #000;
    width: 100%;
    display: inline;
    font-weight: bold;
    height: auto;
    padding: 2px;
    border-bottom: 1px solid #000;
}
.pin{padding: 6px;}

.fl10, .fl20, .fl30, .fl40, .fl50, .fl60, .fl70, .fl80, .fl90, .fl100 {
    padding-bottom:4px;color: #000000;
}

.over{
    background-color: #EFEFDC;
    line-height: 20px;
}

.half{
line-height:50%;
}

.quarter{
line-height:25%;
}

.lh10{
line-height:10%;
}

.checkmargin {margin-right: 25px;}  
.checkmarginL {margin-left: 25px;}  

.pusher {padding-left: 15px;"}
.pusherR {margin-right: 40px;"}

.rand3{background-color: #FFF; line-height: 3px;}
.rand1{background-color: #FFF; line-height: 1px;}

.whiteborder {     color: #ffffff;      border: 4px solid #ffffff;      padding: 10px;      margin: 10px; }
#details { width: 580; color: #ffffff; }
.column1 {     color: #000000; margin: 0;      padding: 0;     width: 500px;     border:0;     float: left; }
.column2 {     color: #000000;margin: 0;      padding: 0;     border:0;     width: 80px;     float: right; }

.f200 {
    color: #000000;
}

.f210 {
    color: #000000;float: left;
}

body
{
background-color:#eeefdf;
}


.form-bg {
  background: #eeefdf;
  width:1000px;
  overflow:hidden;
}

.data-bar {
  border-bottom:1px solid #fbfbf7;
  display:inline-block;
  padding:10px 10px;
}

.left {
float:left;
width:200px;

}

.right {
float:right;
width:700px;
}

.data-box {
width:650px;
height:100px;
border:1px solid #cbcbcb;
}
#table td { 
margin:120px; 
} 

Can you tell me how I should do it? Any other suggestion how I can make my result look more like the specification?

Thank you

Answer by Jules

you can solve it with floating elements like this:

<div style="float:left;width:200px">
    <span>Name</span>
</div>
<div style="float:left">
   <ul style="clear:both">
     <li style="list-style:none">
      <p style="float:left;width:200px;">c o Andersson</p>
      <p style="float:left;width:200px;"> Telefon </p>
      <p style="float:left;width:200px;"> 123456 </p>
     </li>
     <li style="clear:both; list-style:none">
       <p style="float:left;width:200px;">Angeredsgatan</p>
       <p style="float:left;width:200px;">Fax</p>
       <p style="float:left;width:200px;">7551444</p>
     </li>
  </ul>


</div>
    <div style="clear:both;float:left;width:200px">
        <span>name</span>
    </div>
    <div  style="float:left;">
     <span>Munstycke och oftast ett mycket längre krångligt begrepp i en lång lång texststträng längre krångligt begrepp i en lång lång textsträng längre krängligt begrepp i en lång lång textsträng längre krånglig textsträng
      </span>
    </div>

Answer by Starx

colspan is a table feature. It is not available for divs or any other element except table.

Avoid yourself the trouble for looking for one. Becaue, even if you found one, it will be very buggy and simply not worthy to be called a solution.

Read more

Making divs slide down (not open) when a div above is opened

Question by Shaun Woolf

So here’s my question–and I’m not too well versed in programming just yet, so please be patient:

I would like to have a list of objects on my page, with each functioning as a toggle to open a div. That part I have down! What I can’t figure out is how to make it so that divs below the opened object slide below the newly opened div. Currently they just sit there on top the content within the opened div. Thanks!

Answer by Starx

Its called an Accordion Effect. Check out the jQuery UI Accordion Effect here

Here it’s a very simple version of the accordion effect, I just created it using jQuery.

Read more

Javascript stop execution abort or exit

Question by Rocky111

if(a.value==1 && b.value==2)
{
    try{callFunc()  }catch(e) {} 
}
frm.submit();

inside function callFunc() what i have to write so that execution completly stops
it should not execute frm.submit();

function callFunc()
{
    //stop execution here ensure it wont execute fm.submit()
}

Answer by Starx

Cant you just do this?

if(a.value==1 && b.value==2) {}
else {
    frm.submit();
}
Read more

Unable to remove Autofocus in ui-dialog

Question by Josh

The first element in my jQuery UI Dialog is an input, which when selected opens a datepicker…

How can I disable this input from being selected first?

Answer by Starx

Very simple, just trigger the blur event on the input elements when the dialog box opens.

$("#dialog").dialog({
    open: function(event, ui) {
        $("input").blur();
    }
});

Check it out here

Solution with datepicker

NOTE: For more in-depth solution to this problem, read this answer too.

Read more

Update HTML Text Fields

Question by user1178619

How can I update the text fields with HTML? I have a page with some textfields, and I need to update these fields at a specific time. I used the value property to display the default values, but how can I change the values later?

Thank you

Answer by Starx

I am forcing a JavaScript answer, since there is no way it can be done with only HTML.

Snippet:

<input type="text" id="textboxid" />
<script type="text/javascript">
    var txtBox = document.getElementById("textboxid");
    txtBox.value = "new value";
</script>
Read more
...

Please fill the form - I will response as fast as I can!