-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodefest_project_vishal_shivam.php
63 lines (51 loc) · 1.83 KB
/
codefest_project_vishal_shivam.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$check = $_POST['check'];
$text = $_POST['texto'];
$arr = Array();
for($i = 0; $i< sizeof($check); $i++ ) {
$arr[] = "('{$check[$i]}', '{$text[$i]}')";
}
echo 'INSERT INTO `table` (`checkbox`, `texto`) VALUES '.implode($arr, ',');
}
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="../gh-fork-ribbon.css" />
</head>
<body>
<form action="" method="post" id="form">
<input type="checkbox" name="check[]" value="1" /><input type="text" name="texto[]" value="um" disabled="disabled" />
<input type="checkbox" name="check[]" value="2" /><input type="text" name="texto[]" value="dois" disabled="disabled" />
<input type="checkbox" name="check[]" value="3" /><input type="text" name="texto[]" value="tres" disabled="disabled" />
<input type="checkbox" name="check[]" value="4" /><input type="text" name="texto[]" value="quatro" disabled="disabled" />
<input type="checkbox" name="check[]" value="5" /><input type="text" name="texto[]" value="cinco" disabled="disabled" />
<input type="submit" value="ok" />
</form>
<script>
(function(document, undefined){
'use strict';
var $form = document.getElementById('form'),
$check = $form.querySelectorAll('input[type="checkbox"]');
$check = [].slice.call($check);
$check.forEach(function($each) {
$each.addEventListener('click', function(){
var $inputText = this.nextSibling;
if (this.checked) {
$inputText.removeAttribute('disabled');
} else {
$inputText.setAttribute('disabled', 'disabled');
}
});
});
}(document));
</script>
<div class="github-fork-ribbon-wrapper right">
<div class="github-fork-ribbon">
<a href="https://github.com/wbruno/examples">Fork me on GitHub</a>
</div>
</div>
</body>
</html>