php - how to pass multiple text box values in javascript variable? -
<input type="hidden" name="email" value="website_list"> <input type="hidden" name="name" value="john.doe@foo.com"> <input type="hidden" name="fname" value="john">
<script type="text/javascript"> var subscriber_details = { email : 'john.doe@foo.com', name : 'website_list', fname : 'john' } </script>
i want pass hidden value in javascript variable in same manner "subscriber_details" .
so should do?
<script type="text/javascript"> var subscriber_details = { email : "'"+ document.getelementsbyname("email").value +"'", name : "'"+ document.getelementsbyname("name").value +"'", fname : "'"+ document.getelementsbyname("fname").value +"'" } </script>