Click here to Skip to main content
16,011,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all , what i want is to get all values enterd in 5 textboxes(my webform contains) on single onclientclick event of button. is it possible? i can get a single textbox value on onclient click but not all textboxes values. for eg. in empid,empname,salary,city if i enter 4,ram,20000$,canada
when i press enter all values should come on confirm promt. i write a small piece of js code as:
XML
<script type="text/javascript">
    {
        function callall() {

                       txtEmpName = document.getElementById("txtEmpName");
            value = txtEmpName.value;
            confirm(value);
        }
    }
</script>

Thanks, i am in learning phase so please explain whatever you answer.
Posted

use as
JavaScript
function callall() {
  
confirm(document.getElementById("txtEmpName").value +'\n'+document.getElementById("txtsal").value +'\n'+document.getElementById("txtcity").value);
        }
    }
 
Share this answer
 
v2
Comments
Rambo_Raja 12-Jun-13 3:50am    
its not working ...i tried it
uspatel 12-Jun-13 4:48am    
<html>

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

function callall() {
confirm(document.getElementById("txtEmpName").value

+'\n'+document.getElementById("txtsal").value

+'\n'+document.getElementById("txtcity").value);
}

</script>
</head>
<body>
<input id="txtEmpName" type="text"/>
<input id="txtsal" type="text"/>
<input id="txtcity" type="text"/>
<input id="b1" type="button" value="save" önclick="callall();"/>
</body>
</html>


save it as html and run it it is working fine here.
Rambo_Raja 12-Jun-13 4:01am    
do i need to declare the variables as var txtEmpId = document.getElementById().value and so on..
uspatel 12-Jun-13 4:41am    
you do'nt need,you can direct fetch value of an element as I show......
confirm() event is used to return a boolean value (true or false). To simply display the values or message you may use alert() For example if you want the user to confirm before deleting a record you use this function like:
JavaScript
return confirm('Are you sure you want to delete this record?');

In your example above make these changes and test you will see the difference.
JavaScript
<script type="text/javascript">
    {
        function callall() { 
            var empText = document.getElementById("txtEmpName").value;
            alert('You entered: ' + empText); 
            return  confirm('Are you sure you want to post the vale: ' + empText +'?');
        }
    }
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900