Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
e没有javascript错误我的验证下拉菜单控制第一个表单,您仍然希望我从validation(e)中删除内容,还是choicevalidation()?只是确认一下嗨,我尝试了你的答案,但没有成功,如果我点击提交按钮,它会立即提交。我尝试了你的更新,但_Javascript_Jquery_Html - Fatal编程技术网

e没有javascript错误我的验证下拉菜单控制第一个表单,您仍然希望我从validation(e)中删除内容,还是choicevalidation()?只是确认一下嗨,我尝试了你的答案,但没有成功,如果我点击提交按钮,它会立即提交。我尝试了你的更新,但

e没有javascript错误我的验证下拉菜单控制第一个表单,您仍然希望我从validation(e)中删除内容,还是choicevalidation()?只是确认一下嗨,我尝试了你的答案,但没有成功,如果我点击提交按钮,它会立即提交。我尝试了你的更新,但,javascript,jquery,html,Javascript,Jquery,Html,e没有javascript错误我的验证下拉菜单控制第一个表单,您仍然希望我从validation(e)中删除内容,还是choicevalidation()?只是确认一下嗨,我尝试了你的答案,但没有成功,如果我点击提交按钮,它会立即提交。我尝试了你的更新,但仍然提交,没有验证或确认。在执行此操作时,我是否需要更改html中的按钮?您必须打开javascript错误控制台,看看有什么问题。e、 g.更改document.getElementById('curentAssessment').value


e没有javascript错误我的验证下拉菜单控制第一个表单,您仍然希望我从
validation(e)
中删除内容,还是
choicevalidation()
?只是确认一下嗨,我尝试了你的答案,但没有成功,如果我点击提交按钮,它会立即提交。我尝试了你的更新,但仍然提交,没有验证或确认。在执行此操作时,我是否需要更改html中的按钮?您必须打开javascript错误控制台,看看有什么问题。e、 g.更改document.getElementById('curentAssessment').value行;在document.getElementById('currentAssessment').value中;同时移动代码
$('#choiceSubmit')。在('click',函数(e){if(showConfirm(e)){jQuery('#choiceForm').submit()}
inside document ready Function出现错误时,它在错误控制台中没有显示任何内容。但现在它可以工作了,这要感谢anusha对将其移动到document ready的评论。谢谢我知道在测试验证时,代码行在另一页上工作,所以我认为这不是问题所在
    <script type="text/javascript">
    $(document).ready(function () {

        $('#sessionsDrop').change(function () {

            $('#targetdiv').hide();

            if ($(this).val() !== '') {
                var text = $(this).find('option:selected').text();
                var split = text.split(' - ');
                $('#currentId').val($(this).find('option:selected').val());
                $('#currentAssessment').val(split[0]);
                $('#currentDate').val(split[1]);
                $('#currentTime').val(split[2]);
            } else {
                $('#currentAssessment,#currentDate,#currentTime,#currentId').val('');
            }
        });

    });


    function validation(e) {

        var isDataValid = true;

        var moduleTextO = document.getElementById("modulesDrop");

        var errModuleMsgO = document.getElementById("moduleAlert");

        if (moduleTextO.value == "") {
            $('#targetdiv').hide();
            $('#assessmentForm').hide();
            $('#choiceForm').hide();
            $('#submitchoicebtn').hide();
            errModuleMsgO.innerHTML = "Please Select a Module";
            isDataValid = false;
        } else {
            errModuleMsgO.innerHTML = "";
        }

        if (isDataValid === false) {
            if (e.preventDefault) {
                e.preventDefault();
                e.stopPropagation(); //VERY important
            }
            e.returnValue = false;
            e.cancelBubble = true;
        }

        return isDataValid;

    }

    function choicevalidation() {

        var isDataValid = true;

        var currentAssesO = document.getElementById("currentAssessment");

        var currentAssesMsgO = document.getElementById("currentAlert");

        currentAssesMsgO.innerHTML = "";


        if (currentAssesO.value == "") {
            $('#targetdiv').hide();
            currentAssesMsgO.innerHTML = "Please Select an Assessment to edit from the Assessment Drop Down Menu";
            isDataValid = false;
        } else {
            currentAssesMsgO.innerHTML = "";
        }
        return isDataValid;

    }

    function showConfirm() {

        var examInput = document.getElementById('curentAssessment').value;
        var dateInput = document.getElementById('currentDate').value;
        var timeInput = document.getElementById('currentTime').value;

        if (choicevalidation()) {

            var confirmMsg = confirm("Are you sure you want to take the following Assessment:" + "\n" + "Exam: " + examInput + "\n" + "Date: " + dateInput + "\n" + "Time: " + timeInput);

            if (confirmMsg == true) {
                submitform();
            }
        }
    }

    $('#choiceForm').on('submit', showConfirm);
</script>
 <h1>TAKE AN ASSESSMENT</h1> //FORM 1
<form action="assessmentchoice.php" method="post" onsubmit="return validation(event);">
    <table>
        <tr>
            <th>Module:
                <select name="modules" id="modulesDrop">
                    <option value="">Please Select</option>
                    <option value="CHI2513_Systems Strategy_1">CHI2513 - Systems Strategy</option>
                    <option value="CHT2220_Interactive Systems_4">CHT2220 - Interactive Systems</option>
                </select>
            </th>
        </tr>
    </table>
    <p>
        <input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit"
        />
    </p>
    <div id="moduleAlert"></div>
    <div id="targetdiv"></div>
</form>//FORM 2
<div id='lt-container'>
    <form action='assessmentchoice.php' method='post' id='assessmentForm'>
        <p id='warnings'></p>
        <p><strong>Selected Module:</strong> CHI2513 - Systems Strategy
            <input type='hidden'
            value='1'>
        </p>
        <p><strong>Assessments:</strong> 
            <select name="session" id="sessionsDrop">
                <option value="">Please Select</option>
                <option value='28'>LDREW - 09-01-2013 - 09:00</option>
                <option value='29'>BQNYF - 10-01-2013 - 10:00</option>
                <option value='22' disabled>WDFRK - 17-01-2013 - 09:00</option>
                <option value='26' disabled>POKUB1 - 25-01-2013 - 15:00</option>
            </select>
        </p>
    </form>
</div>
<div id='rt-container'>//FORM 3 (This is where when submitted it should show confirmation)
    <form
    id='choiceForm' action='assessment.php' method='post'>
        <p><strong>Chosen Assessment:</strong>
        </p>
        <table>
            <tr>
                <th></th>
                <td>
                    <input type='hidden' id='currentId' name='Idcurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
            <tr>
                <th>Assessment:</th>
                <td>
                    <input type='text' id='currentAssessment' name='Assessmentcurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
            <tr>
                <th>Date:</th>
                <td>
                    <input type='text' id='currentDate' name='Datecurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
            <tr>
                <th>Start Time:</th>
                <td>
                    <input type='text' id='currentTime' name='Timecurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
        </table>
        <div id='currentAlert'></div>
        <p id='submitchoicebtn'>
            <button id='choiceSubmit'>Choose Assessment</button>
        </p>
        </form>
function validation(e) {
  return false;
}
function showConfirm() { /* your existing code */ }
function showConfirm(e) {
    e.preventDefault();

    /* your existing code */

    return false;
}
function showConfirm(e) {
    e.preventDefault();

    var examInput = document.getElementById('curentAssessment').value;
    var dateInput = document.getElementById('currentDate').value;
    var timeInput = document.getElementById('currentTime').value;

    if (choicevalidation()) {

        return confirm("Are you sure you want to take the following Assessment:" + "\n" + "Exam: " + examInput + "\n" + "Date: " + dateInput + "\n" + "Time: " + timeInput);
    }
    return false;
}

$('#choiceSubmit').on('click', function(e) {
    if (showConfirm(e)) {
        $('#choiceForm').submit();
    }
});
$('#choiceSubmit').click(function(e) {
    e.preventDefault();
    var x = 0;
    if (showConfirm(e)) {
        $('#choiceForm').submit();
    }
});