Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access my form values in document.ready

I am new to javascript and have a very basic question:

I have this in my HTML

Total Cost: <input type="text" name="total" id="total" class="MyInput" />  

I want to assign a value to this textbox at the program startup, for that I am using document.ready, but its not working.

<SCRIPT LANGUAGE="JavaScript">
    $(document).ready(function() {{
        $("#total").value  = "2";
    });

What is the correct way of doing this?

like image 387
junaidp Avatar asked Nov 28 '11 10:11

junaidp


1 Answers

Do:

   $(document).ready(function(){
         $("#total").val('2');
   });
like image 51
Sudhir Bastakoti Avatar answered Oct 21 '22 16:10

Sudhir Bastakoti