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

  • SEARCH
  • Home
  • 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 8937319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:23:27+00:00 2026-06-15T10:23:27+00:00

This seems really odd to me, but my popup confirm box will work when

  • 0

This seems really odd to me, but my popup confirm box will work when i just call the function, but as soon as i try to get a value from a form in my php code, the popup box doesnt work at all!

javascipt:

function ConfirmBox(){
    cert = cValForm.elements["cVal"].value;
    answer = confirm("Are you sure you want to delete " + cert + " and all of its courses?");
     if (answer){
         alert("Entry Deleted");
     }
     else{
         alert("No action taken");
     }             
}

PHP:

echo "<form name='cValForm'>";
echo "<input type='hidden' name='cVal' value='TEST' /> ";
echo "<input type='button' onclick='ConfirmBox()' value='Delete'/>";
echo "</form>";

As soon as i comment out the line:

cert = cValForm.elements["cVal"].value;

As well as getting rid of the cert value in the string, the popup works completely fine. Am i getting the value from the form wrong? Or am i completely missing something here? Thanks!

  • 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-15T10:23:29+00:00Added an answer on June 15, 2026 at 10:23 am

    I think you script breaks, because it is not able to find the value of the cVal field.

    Change your HTML to use Ids as well as names:

    <form name='cValForm'>
      <input type='hidden' id="cVal" name='cVal' value='TEST' />
      <input type='button' onclick='ConfirmBox()' value='Delete'/>
    </form>
    

    And then check in JavaScript first, if the element was selected at all:

    function ConfirmBox(){
        var certField = document.getElementById( 'cVal' );
        var cert = certField ? certField.value : '';
        var answer = confirm("Are you sure you want to delete " + cert + " and all of its courses?");
         if (answer){
             alert("Entry Deleted");
         }
         else{
             alert("No action taken");
         }             
    }
    

    Besides, you should add the keyword var to all you variable declarations to limit the scope of these vars to the local function. In your case those variables would have been global, which may have some side-effects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems really simple but I can't see that NSNumberFormatter has a function for
This seems really dumb. I've tried a bunch of different ways and it's just
This really seems like a bug to me, but perhaps some databinding gurus can
Ok, so this seems like a really silly problem but I can't get my
This seems like it should be really simple, but I'm unable to figure this
This seems like it should be really easy but I couln't find an answer
this seems to be weird but it really happened. I have this code working
I'm pretty certain I'm missing something really obvious here but this seems quite bizarre.
IE6 is always surprising me but this one is REALLY odd. I'm creating a
This seems really easy (I've done it a million times and never had a

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.