Please have a look at this code.
$('#displayname').val(prompt('Enter your name:', ''));
$('#groupname').val(prompt('Enter your Group:', ''));
alert($('#displayname').val());
alert($('#groupname').val());
I read values for two variables displayname and groupname respectively through javascript prompts. Then when i alert these two variables displayname alerts the real value,whereas groupname is alerted as undefined. I could not find any syntactical errors. What can be the possible reason ? Thank You in advance.
#displaynameand#groupnameare (or should be) elements on the page, not variables. I don't know if that's what you meant by "variables", but I thought I would clarify in case of confusion. To use variables, it should bevar groupName = someValue;.