Get Form value with jQuery

Developer
Size
1,931 Kb
Views
6,072

How do I make an get form value with jquery?

What is a get form value with jquery? How do you make a get form value with jquery? This script and codes were developed by Tommy on 30 December 2022, Friday.

Get Form value with jQuery Previews

Get Form value with jQuery - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Get Form value with jQuery</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <a href="">button</a>
<form id="my-form"> <input type="text" name="my-text" value="This is text." />
<hr /> <input type="radio" name="my-radio" value="A" /> <input type="radio" name="my-radio" value="B" checked /> <input type="radio" name="my-radio" value="C" />
<hr /> <input type="checkbox" name="my-checkbox" value="A" /> <input type="checkbox" name="my-checkbox" value="B" checked /> <input type="checkbox" name="my-checkbox" value="C" checked />
<hr /> <select name="my-select"> <option value="A">This is A</option> <option value="B" selected>This is B</option> <option value="C">This is C</option> </select>
<hr /> <select name="my-multi-select" size="3" multiple> <option value="A">This is A</option> <option value="B" selected>This is B</option> <option value="C" selected>This is C</option> </select>
</form> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Get Form value with jQuery - Script Codes JS Codes

$("a").click(function() { // TEXT var valText = $('#my-form [name=my-text]').val(); console.log(valText); // => "This is text." // RADIO var valRadio = $('#my-form [name=my-radio]:checked').val(); console.log(valRadio); // => "B" // CHECKBOX var $checked = $('#my-form [name=my-checkbox]:checked'); var valList = $checked.map(function(index, el) { return $(this).val(); }); console.log(valList); // => ["B", "C"] // SELECT var valSelect = $('#my-form [name=my-select]').val(); console.log(valSelect); // => "B" // LABEL INSTEAD OF VALUE var valLabel = $('#my-form [name=my-select] option:selected').text(); console.log(valLabel); // => "This is B" // MULTIPLE SELCT var valMultiSelect = $('#my-form [name=my-multi-select]').val(); console.log(valMultiSelect); // => ["B", "C"]
});
Get Form value with jQuery - Script Codes
Get Form value with jQuery - Script Codes
Home Page Home
Developer Tommy
Username hoehoe
Uploaded December 30, 2022
Rating 3
Size 1,931 Kb
Views 6,072
Do you need developer help for Get Form value with jQuery?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Tommy (hoehoe) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!