我在数据库表中有位置名称和位置ID.使用foreach循环我在PHP中的复选框中打印值.我有一个触发javascript的提交按钮.我希望用户在javascript变量中选择以逗号分隔的所有复选框值.我怎样才能做到这一点?
<!-- Javascript -->
<script>
function getLoc(){
var all_location_id = document.getElementByName("location[]").value;
var str = <!-- Here I want the selected checkbox values, eg: 1, 4, 6 -->
}
<script>
foreach($cityrows as $cityrow){
echo '<input type="checkbox" name="location[]" value="'.$cityrow['location_id'].'" />'.$cityrow['location'];
echo '<br>';
}
echo '<input name="searchDonor" type="button" class="button" value="Search Donor" onclick="getLoc()" />';
Run Code Online (Sandbox Code Playgroud) 我想通过其isbn数搜索书籍信息并检索信息并显示/存储信息的结果.
例如,我使用以下url
https://www.googleapis.com/books/v1/volumes?q=isbn:9789381141977
{
"kind": "books#volumes",
"totalItems": 1,
"items": [
{
"kind": "books#volume",
"id": "j5jFmAEACAAJ",
"etag": "7QZKCyFvQv0",
"selfLink": "https://www.googleapis.com/books/v1/volumes/j5jFmAEACAAJ",
"volumeInfo": {
"title": "Wireless Communication Systems",
"authors": [
"Rajeshwar Dass, Sr."
],
"publishedDate": "2012-11-27",
"industryIdentifiers": [
{
"type": "ISBN_10",
"identifier": "9381141975"
},
{
"type": "ISBN_13",
"identifier": "9789381141977"
}
],
"pageCount": 200,
"printType": "BOOK",
"categories": [
"Science"
],
"contentVersion": "preview-1.0.0",
"language": "en",
"previewLink": "http://books.google.co.in/books?id=j5jFmAEACAAJ&dq=isbn:9789381141977&hl=&cd=1&source=gbs_api",
"infoLink": "http://books.google.co.in/books?id=j5jFmAEACAAJ&dq=isbn:9789381141977&hl=&source=gbs_api",
"canonicalVolumeLink": "http://books.google.co.in/books/about/Wireless_Communication_Systems.html?hl=&id=j5jFmAEACAAJ"
},
"saleInfo": {
"country": "IN",
"saleability": "NOT_FOR_SALE",
"isEbook": false
},
"accessInfo": {
"country": "IN", …Run Code Online (Sandbox Code Playgroud)