JavaScript Function:- the function is call on submit buttion.
function getFormElelemets(obj){
var form = $(obj).closest('form'); // id of form tag related to the
var formid = form.attr('id');
var name='sampledate'; // id of element for set focus
alert(formid );
document.formid.name.focus();
return false;
}
Problem Statement:- the function get call successfully but after the alert if i press 'ok' the focus not move curser to the form element.servlate get called with and url shows all the paramter with there value.am generating multiple form dynamically with the unique id.Please provide solution.
Just use a jQuery id
selector #
and .focus()
function:
function getFormElelemets(obj){
var form = $(obj).closest('form');
var formid = form.attr('id');
var name = '#sampledate'; // id's starts with '#'
alert(formid);
$(name).focus(); // select element with jQuery and set focus
return false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.