Expand|Select|Wrap|Line Numbers
- <select name="rNumber" title="number of ticket"
- onChange="GoToNextPage(this.value)">
- <option selected>Select</option>
- <option>01</option>
- <option>02</option>
- <option>03</option>
- <option>04</option>
- <option>05</option>
- <option>06</option>
- </select>
Expand|Select|Wrap|Line Numbers
- <script language="JavaScript" type="text/JavaScript">
- function validate(which) {
- var selects = which.getElementsByTagName('select');
- var radios = which.getElementsByTagName('input');
- for(sel = 0; sel < selects.length; sel++) {
- if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
- alert('Please select number of ticket!');
- return false;
- }
- }
- var rselCount = 0;
- for(radio = 0; radio < radios.length; radio++) {
- if(radios[radio].checked) {
- rselCount++;
- }
- }
- if(rselCount == 0) {
- alert('Please select screening time!');
- return false;
- }
- return true;
- }
- function GoToNextPage(value){
- if(value != ""){
- document.location = 'reservation3.php?selected_no_ticket=' + value;
- }
- }
Expand|Select|Wrap|Line Numbers
- <form action="reservation3.php" method="post" name="movieList"
- onSubmit="return validate(this);">
alert('Please select screening time!'); when radio button was not selected.What went wrong in the script?Thanks...