How to pass JavaScript function to the INPUT HTML tag -


this want.

<form> <input type="text" name="date" value="currentdate()"> .....</form> 

here want set default value current date.

i don't think can that.

but work:

var today = new date();  var dd = today.getdate();  var mm = today.getmonth()+1; //january 0!  var yyyy = today.getfullyear();    if(dd<10) {    dd='0'+dd  }     if(mm<10) {    mm='0'+mm  }     today = mm+'/'+dd+'/'+yyyy;    document.getelementbyid('date').value=today ;
<form>    <input type="text" name="date" id="date">  </form>

i got solution samuel's answer in this post.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -