jquery .val() unidentified
Ik heb de volgende code:
Code (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<div class="tab-pane" id="type">
<h4 class="info-text">
What type of cruise would you want?
</h4>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 99 From 12pm to 4pm">
<input type="radio" id="ctype" name="ctype" value="lunch">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Lunch
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 149 From 4pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="dinner">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Dinner
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 239 From 12pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="day">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Day
</h6>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
people
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of adults
</label>
<input name="amountAdults" type="number" class="form-control">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
group_add
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of Childern
</label>
<input name="amountChildern" type="number" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="details">
<div class="row">
<h4 class="info-text"> Pick a date you would like to go</h4>
<div class="col-sm-12">
<div style="height: 500px;" id="datepicker"></div>
</div>
</div>
</div>
<input type='button' class='btn btn-next btn-fill btn-info btn-wd' onclick="getValues()" name='next' value='Next' />
function getValues()
{
alert($( "input[type=radio][name=ctype]:checked" ).val());
}
<h4 class="info-text">
What type of cruise would you want?
</h4>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 99 From 12pm to 4pm">
<input type="radio" id="ctype" name="ctype" value="lunch">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Lunch
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 149 From 4pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="dinner">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Dinner
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 239 From 12pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="day">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Day
</h6>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
people
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of adults
</label>
<input name="amountAdults" type="number" class="form-control">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
group_add
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of Childern
</label>
<input name="amountChildern" type="number" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="details">
<div class="row">
<h4 class="info-text"> Pick a date you would like to go</h4>
<div class="col-sm-12">
<div style="height: 500px;" id="datepicker"></div>
</div>
</div>
</div>
<input type='button' class='btn btn-next btn-fill btn-info btn-wd' onclick="getValues()" name='next' value='Next' />
function getValues()
{
alert($( "input[type=radio][name=ctype]:checked" ).val());
}
Ik zie nergens een fout staan in de code, waardoor het script met alert niet werkt. Als resultaat geeft hij terug: unidentified, maar de value zou dinner, lunch of day moeten zijn. Ik heb in de broncode gekeken, als ik daar één van de drie aanklik staat er wel gewoon checked="checked". Ik ben er al een uur mee bezig om te achterhalen waar de fout is, maar kom er simpel niet uit. Alvast bedankt voor de hulp
Gewijzigd op 09/03/2019 13:24:34 door - Rob -
Waarom trouwens die type=radio er nog bij. Enkel name=ctype is toch voldoende (dat zijn enkel maar radio's)?
Misschien quootjes:
Wat in ieder geval niet klopt is het hergebruik van id="ctype".
Weet je zeker dat je JavaScript nergens anders breekt? En waar zijn je form tags?
Bijna letterlijk dezelfde vraag op SO
Thomas van den Heuvel op 09/03/2019 13:40:46:
Dit zou moeten werken? Heb je ook simpelweg [name=ctype] geprobeerd, eventueel met quotes?
Wat in ieder geval niet klopt is het hergebruik van id="ctype".
Weet je zeker dat je JavaScript nergens anders breekt? En waar zijn je form tags?
Bijna letterlijk dezelfde vraag op SO
Wat in ieder geval niet klopt is het hergebruik van id="ctype".
Weet je zeker dat je JavaScript nergens anders breekt? En waar zijn je form tags?
Bijna letterlijk dezelfde vraag op SO
De form tags zitten helemaal van boven, echter werken de andere oplossingen ook niet die zijn genoemd. ;\
Code (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
Umoja - Bookings
</title>
<!-- Import all css files -->
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" id="bootstrap-css">
<link rel="stylesheet" href="assets/css/index.css" />
<link rel="stylesheet" href="assets/dist/datepickk.min.css" />
<!-- Import al javascript files -->
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/index.js"></script>
<script type="text/javascript" src="assets/dist/datepickk.min.js"></script>
</head>
<body>
<div>
<!-- Logo and name in left top (DISABLED) -->
<!--
<a href="#">
<div class="logo-container">
<div class="logo">
<img src="">
</div>
<div class="brand">
Something
</div>
</div>
</a>
-->
<!-- Info bar right bottom (DISABLED) -->
<!--
<a href="#" class="made-with-mk">
<div class="brand">
Something
</div>
<div class="made-with">
Something
</div>
</a>
-->
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<div class="wizard-container">
<div class="card wizard-card" data-color="blue" id="wizard">
<form method="POST">
<div class="wizard-header">
<h3 class="wizard-title">
Book a cruise
</h3>
<h5>
This information will let us know what kind of cruise you want
</h5>
</div>
<!-- Menu with content -->
<div class="wizard-navigation">
<ul>
<li>
<a href="#type" data-toggle="tab">
Cruise Type
</a>
</li>
<li>
<a href="#details" data-toggle="tab">
Details
</a>
</li>
<li>
<a href="#extradetails" data-toggle="tab">
Extra Details
</a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane" id="type">
<h4 class="info-text">
What type of cruise would you want?
</h4>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 99 From 12pm to 4pm">
<input type="radio" id="ctype" name="ctype" value="lunch">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Lunch
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 149 From 4pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="dinner">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Dinner
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 239 From 12pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="day">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Day
</h6>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
people
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of adults
</label>
<input name="amountAdults" type="number" class="form-control">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
group_add
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of Childern
</label>
<input name="amountChildern" type="number" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="details">
<div class="row">
<h4 class="info-text"> Pick a date you would like to go</h4>
<div class="col-sm-12">
<div style="height: 500px;" id="datepicker"></div>
</div>
</div>
</div>
<div class="tab-pane" id="extradetails">
<div class="row">
<div class="col-sm-12">
<h4 class="info-text">
Let's go on with your details
</h4>
</div>
<div class="col-sm-6">
<!-- Input ... -->
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
person
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your name
</label>
<input name="name" type="text" class="form-control">
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
email
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your Email
</label>
<input name="email" type="email" class="form-control">
</div>
</div>
<div style="margin-left: 20px;" class="input-group">
<label class="control-label" style="font-size: 11pt;"><b>Sex</b></label>
<div style="margin-top: -13px;" class="form-group label-floating">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary">
<input type="radio" name="sex" autocomplete="off" value="male" required="" aria-required="true"> Male
<div class="ripple-container"></div>
</label>
<label class="btn btn-secondary">
<input type="radio" name="sex" autocomplete="off" value="female">
Female
</label>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
phone
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your primary phonenumber
</label>
<input name="primphone" type="text" class="form-control">
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
phone
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your secundary phonenumber
</label>
<input name="secphone" type="text" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="wizard-footer">
<div class="pull-right">
<input type='button' class='btn btn-next btn-fill btn-info btn-wd' onclick="getValues()" name='next' value='Next' />
<input type='button' class='btn btn-finish btn-fill btn-info btn-wd' name='finish' value='Finish' />
</div>
<div class="pull-left">
<input type='button' class='btn btn-previous btn-fill btn-default btn-wd' name='previous' value='Previous' />
<div class="footer-checkbox">
<div class="col-sm-12">
<div class="checkbox">
<label>
<input type="checkbox" name="toc">
</label>
I accept the <b><a style="color: black;" href="#">Terms of Condition</a></b>
</div>
</div>
</div>
</div>
<div class="clearfix">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="container text-center">
Made with <i class="fa fa-heart heart"></i> by <a href="http://www.creative-tim.com" target="_blank">Creative Tim</a>.
</div>
</div>
</div>
</body>
<footer>
<script>
var datepicker = new Datepickk({
container: document.querySelector('#datepicker'),
inline: true,
range: false,
});
datepicker.minDate = new Date();
datepicker.maxSelections = 1;
datepicker.weekStart = 1;
function getValues()
{
alert($( "input[name='ctype']:checked" ).val());
}
</script>
</footer>
</html>
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
Umoja - Bookings
</title>
<!-- Import all css files -->
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" id="bootstrap-css">
<link rel="stylesheet" href="assets/css/index.css" />
<link rel="stylesheet" href="assets/dist/datepickk.min.css" />
<!-- Import al javascript files -->
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/index.js"></script>
<script type="text/javascript" src="assets/dist/datepickk.min.js"></script>
</head>
<body>
<div>
<!-- Logo and name in left top (DISABLED) -->
<!--
<a href="#">
<div class="logo-container">
<div class="logo">
<img src="">
</div>
<div class="brand">
Something
</div>
</div>
</a>
-->
<!-- Info bar right bottom (DISABLED) -->
<!--
<a href="#" class="made-with-mk">
<div class="brand">
Something
</div>
<div class="made-with">
Something
</div>
</a>
-->
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<div class="wizard-container">
<div class="card wizard-card" data-color="blue" id="wizard">
<form method="POST">
<div class="wizard-header">
<h3 class="wizard-title">
Book a cruise
</h3>
<h5>
This information will let us know what kind of cruise you want
</h5>
</div>
<!-- Menu with content -->
<div class="wizard-navigation">
<ul>
<li>
<a href="#type" data-toggle="tab">
Cruise Type
</a>
</li>
<li>
<a href="#details" data-toggle="tab">
Details
</a>
</li>
<li>
<a href="#extradetails" data-toggle="tab">
Extra Details
</a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane" id="type">
<h4 class="info-text">
What type of cruise would you want?
</h4>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 99 From 12pm to 4pm">
<input type="radio" id="ctype" name="ctype" value="lunch">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Lunch
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 149 From 4pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="dinner">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Dinner
</h6>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-radio" rel="tooltip" title="The price of this cruise is 239 From 12pm to 9pm">
<input type="radio" id="ctype" name="ctype" value="day">
<div class="icon">
<i class="material-icons">
directions_boat
</i>
</div>
<h6>
Day
</h6>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
people
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of adults
</label>
<input name="amountAdults" type="number" class="form-control">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
group_add
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Amount of Childern
</label>
<input name="amountChildern" type="number" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="details">
<div class="row">
<h4 class="info-text"> Pick a date you would like to go</h4>
<div class="col-sm-12">
<div style="height: 500px;" id="datepicker"></div>
</div>
</div>
</div>
<div class="tab-pane" id="extradetails">
<div class="row">
<div class="col-sm-12">
<h4 class="info-text">
Let's go on with your details
</h4>
</div>
<div class="col-sm-6">
<!-- Input ... -->
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
person
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your name
</label>
<input name="name" type="text" class="form-control">
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your Email
</label>
<input name="email" type="email" class="form-control">
</div>
</div>
<div style="margin-left: 20px;" class="input-group">
<label class="control-label" style="font-size: 11pt;"><b>Sex</b></label>
<div style="margin-top: -13px;" class="form-group label-floating">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary">
<input type="radio" name="sex" autocomplete="off" value="male" required="" aria-required="true"> Male
<div class="ripple-container"></div>
</label>
<label class="btn btn-secondary">
<input type="radio" name="sex" autocomplete="off" value="female">
Female
</label>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
phone
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your primary phonenumber
</label>
<input name="primphone" type="text" class="form-control">
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">
phone
</i>
</span>
<div class="form-group label-floating">
<label class="control-label">
Your secundary phonenumber
</label>
<input name="secphone" type="text" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="wizard-footer">
<div class="pull-right">
<input type='button' class='btn btn-next btn-fill btn-info btn-wd' onclick="getValues()" name='next' value='Next' />
<input type='button' class='btn btn-finish btn-fill btn-info btn-wd' name='finish' value='Finish' />
</div>
<div class="pull-left">
<input type='button' class='btn btn-previous btn-fill btn-default btn-wd' name='previous' value='Previous' />
<div class="footer-checkbox">
<div class="col-sm-12">
<div class="checkbox">
<label>
<input type="checkbox" name="toc">
</label>
I accept the <b><a style="color: black;" href="#">Terms of Condition</a></b>
</div>
</div>
</div>
</div>
<div class="clearfix">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="container text-center">
Made with <i class="fa fa-heart heart"></i> by <a href="http://www.creative-tim.com" target="_blank">Creative Tim</a>.
</div>
</div>
</div>
</body>
<footer>
<script>
var datepicker = new Datepickk({
container: document.querySelector('#datepicker'),
inline: true,
range: false,
});
datepicker.minDate = new Date();
datepicker.maxSelections = 1;
datepicker.weekStart = 1;
function getValues()
{
alert($( "input[name='ctype']:checked" ).val());
}
</script>
</footer>
</html>
Toevoeging op 09/03/2019 14:05:44:
EDIT:
Als ik in de code direct toevoeg dat de input checked is, werkt het systeem wel, als ik het type dan niet meer aanpas. Het vreemde vind ik dus dat als ik het type verander dat ik de alert unidentified krijg, terwijl er in de broncode wel checked="checked" zie staan
Amount of Childern -> Number of childern
In ieder geval, bedankt voor de hulp
Dit werkt prima (input ipv button werkt ook):
Code (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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jquery checked test</title>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<form>
<input type="radio" id="ctype_lunch" name="ctype" value="lunch"> <label for="ctype_lunch">lunch</label><br>
<input type="radio" id="ctype_dinner" name="ctype" value="dinner"> <label for="ctype_dinner">dinner</label><br>
<input type="radio" id="ctype_day" name="ctype" value="day"> <label for="ctype_day">day</label><br>
<button type="button" onclick="getValues()">click me</button>
</form>
<script>
function getValues() {
$radio = $("input[name='ctype']:checked");
if ($radio.length > 0) {
alert($radio.val());
} else {
alert('nothing selected!');
}
}
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>jquery checked test</title>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<form>
<input type="radio" id="ctype_lunch" name="ctype" value="lunch"> <label for="ctype_lunch">lunch</label><br>
<input type="radio" id="ctype_dinner" name="ctype" value="dinner"> <label for="ctype_dinner">dinner</label><br>
<input type="radio" id="ctype_day" name="ctype" value="day"> <label for="ctype_day">day</label><br>
<button type="button" onclick="getValues()">click me</button>
</form>
<script>
function getValues() {
$radio = $("input[name='ctype']:checked");
if ($radio.length > 0) {
alert($radio.val());
} else {
alert('nothing selected!');
}
}
</script>
</body>
</html>
Waarschijnlijk breekt je JavaScript ergens anders?
Als ik de input BUITEN de div met class choice zet, werkt het wel, maar binnen de div met de class choice werkt het niet. Breekt mijn js dan? Enig idee hoe ik dit moet oplossen?
Toevoeging op 10/03/2019 10:11:50:
FIX:
Ik heb in de div (waar de class choice in zit) een onclick toegevoegd met de functie: changeType(CRUISETYPE), vervolgens heb ik een hidden input gemaakt (type=text) met de name cruisetype, elke keer als iemand op een één van de drie radio buttons drukt, verandert de hidden input value naar de soort cruise, die bij changeType is ingevoerd. Ik vind het vreemd dat het niet werkt als de input in de class choice zit, maar het werkt nu in ieder geval goed genoeg.