Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:36:02+00:00 2026-06-14T04:36:02+00:00

I have this javascript and php/html code below: <script> var examInput = document.getElementById(‘newAssessment’).value; var

  • 0

I have this javascript and php/html code below:

<script>
          var examInput = document.getElementById('newAssessment').value;
          var dateInput = document.getElementById('newDate').value;
          var timeInput = document.getElementById('newTime').value;

         function showConfirm(){

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

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

</script>

….

<?php

$editsession = "<form action=".htmlentities($_SERVER['PHP_SELF'])." method='post' id='updateForm'>

    <p><strong>New Assessment's Date/Start Time:</strong></p>
    <table>
    <tr>
    <th>Assessment:</th>
    <td><input type='text' id='newAssessment' name='Assessmentnew' readonly='readonly' value='' /> </td>
    </tr>
    <tr>
    <th>Date:</th> 
    <td><input type='text' id='newDate' name='Datenew' readonly='readonly' value='' /> </td>
    </tr>
    <tr>
    <th>Start Time:</th> 
    <td><input type='text' id='newTime' name='Timenew' readonly='readonly' value=''/><span class='timepicker_button_trigger'><img src='Images/clock.gif' alt='Choose Time' /></span> </td>
    </tr>
    </table>
    <div id='datetimeAlert'></div>


    </form>
";

echo $editsession;


?>

The problem is that in the confirmation box, it is not displaying the name of the exam, the date and time which are all displayed in the textboxes in the php/html.

For example it should display:

Are you sure you want to update the following:
Exam: DFRER
Date: 20-02-2013
Time: 16:00

Instead it displays:

Are you sure you want to update the following:
Exam: undefined
Date: undefined
Time: undefined

Why is this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:36:03+00:00Added an answer on June 14, 2026 at 4:36 am

    <script> tags execute as soon as they are encountered in the markup. We assume your <script> tag occurs before the HTML it references in its getElementById() calls.

    Since the three lines that set the variables occur outside any function they and are executed immediately, before the DOM is loaded, the respective DOM elements don’t yet exist and the variables become undefined. Just move them into the function. This has the added benefit of the values being up to date any subsequent time you call the function.

     function showConfirm(){
       // Load these variables inside the function
       // If placed outside, their DOM nodes are not yet loaded when the script runs
       var examInput = document.getElementById('newAssessment').value;
       var dateInput = document.getElementById('newDate').value;
       var timeInput = document.getElementById('newTime').value;
    
       var confirmMsg=confirm("Are you sure you want to update the following:" + "\n" + "Exam: " + examInput +  "\n" + "Date: " + dateInput + "\n" + "Time: " + timeInput);
    
       if (confirmMsg)
       {
         submitform();   
       }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP File with something like this: <script type=text/javascript> var page =
I have this Javascript: <script language=javascript type=text/javascript> $().ready(function() { $('#ex2').jqm({ajax: 'view.php?id=<?=$objResult[id];?>', trigger: 'a.ex2trigger'}); });
I have this Javascript/JQuery code: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script type=text/javascript> name = $(#name).val(); alert(Name:
I have this javascript code below that uses jquery, it is suppoed to be
I have this JavaScript code: for (var idx in data) { var row =
I have a code like this. <html> <head> <title>Captcha With Refresh Feature</title> <script src=jquery.js
I have a page as below: <head> <script type="text/javascript" src="jquery-1.6.1.js"></script> <script type="text/javascript"> $(document).ready( function()
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; if(form.fName.value ==
I have this Javascript function that sends username and password to php file through
I have this chunk of javascript that's kind of hacked around from http://www.developphp.com/view.php?tid=1248 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.