Created
January 1, 2020 10:43
-
-
Save tamimibrahim17/45214cb668c9702fd0203cbf6c31903a to your computer and use it in GitHub Desktop.
test2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>test</title> | |
</head> | |
<body> | |
<form action="" id="test"> | |
<input name="invoice_items[0][ProductName]" class="invoice_item" value="Shoe (14cm)" type="text"> | |
<input name="invoice_items[0][UnitPrice]" class="invoice_item" value="800" type="text"> | |
<input name="invoice_items[0][QT]" class="invoice_item" value="1" type="number"> | |
<input name="invoice_items[0][RowId]" class="invoice_item" value="177" type="text"> | |
</form> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script> | |
jQuery(document).ready(function($) { | |
var output = []; | |
output['invoice_items'] = {}; | |
var data = $('#test').serializeArray(); | |
data['type'] = 'update'; | |
$(data).each(function(key,value){ | |
var split = value['name'].match(/invoice_items\[(\w)\]\[(\w+)\]/); | |
console.log(split[1]); | |
cc = {}; | |
cc[split[2]] = value.value; | |
output['invoice_items'][split[1]] = cc; | |
}); | |
console.log(output); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment