Print Value On Form Submit
I'm new to JavaScript. How can I print the values when an HTML form is submitted?
Solution 1:
Assuming your form looks like :
<formaction=""><inputtype="text"name="User" /><inputtype="password"name="Password"/><span>Admin</span><inputtype="checkbox"name="IsAdmin" /><span>US</span><inputtype="radio"name="Country"value="US" /><span>UK</span><inputtype="radio"name="Country"value="UK" /><inputtype="submit" /></form>
Jquery code should look like this as starting point :
<scripttype="text/javascript">
$(document).ready(function () {
$("form").submit(function () {
User = $("input[name='User']").val();
Password = $("input[name='Password']").val();
IsAdmin = $("input[name='IsAdmin']").attr("checked");
Country = $("input:radio[name='Country']:checked").val(); /* Special case of radio buttons*/document.writeln(User);
document.writeln(Password);
document.writeln(IsAdmin);
document.writeln(Country);
returnfalse;
})
});
</script>
Post a Comment for "Print Value On Form Submit"