Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The script in the code below is giving error:
Uncaught ReferenceError: TrialScript is not defined



<html>
<head>
<Title>Demo Script</Title>

 <script type="text/javascript">
                function TrialScript()
                {
				    if (confirm('Are you sure you want to proceed?') == true) 
                    { 
						document.getElementById('Hidden1').value = 'yes'; 
                    } 
                    else   
                    {  
                        document.getElementById('Hidden1)'.value = 'no';
                    }
                }
                
            </script>


</head>

<body onload="TrialScript();">

<input id="Hidden1" type="hidden" />

</body>

</html>


What I have tried:

I have done all form of searching and debugging, but couldn't get it.
Posted
Updated 14-Aug-17 4:37am

1 solution

document.getElementById('Hidden1)'.value = 'no';
Your closing quote on Hidden1 is outside the bracket.
 
Share this answer
 
Comments
Saintniyi 14-Aug-17 11:46am    
Thanks a million times. It works like charms. I can't believe a single misplaced quote will give me sleepless night. Many thanks.
Peter_in_2780 14-Aug-17 21:53pm    
You're welcome. Given the way Javascript just "disappears" on syntax errors, I find a syntax-colouring editor essential.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900