The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> HTML/JS help, Cannot find error
skyward
post Feb 16 2016, 02:16 AM
Post #1





Group: Members
Posts: 7
Joined: 16-February 16
Member No.: 23,998



Hi

I am absolutely new to html and javascript. I have developed a simple form in html that is checked through a js function through an onClick event. The problem is that the function is not being executed although there does not seem to be any errors. i have checked it through the w3school debugger and firebug but i am really confused because i DON'T KNOW whats wrong. I need urgent help with this and will appreciate any pointers.

thanks

here is the code

<!DOCTYPE html>
<HTML>
<HEAD>
<title>Online Job Portal</title>

<script type="text/javascript">

function checkForm()
{
document.write("Working");
var chk=true;

var name=document.getElementById("fullname").value;
var age=document.getElementById("getage").value;
var under=document.getElementById("under").checked;
var grad=document.getElementById("grad").checked;

if(name==""){
chk=false;
window.alert("Name is required");}
if(isNaN(age)||age<1||age>100){
chk=false;
window.alert("Enter Valid Age");}
if(under==false && grad==false){
chk=false;
window.alert("Select Qualification");}

if(chk==false){
document.getElementById("info").innerHTML="Please give your information correctly";}

if (chk==false){
var qual=document.getElementById("under").checked;
var it=document.getElementById("it").checked;
var marketing=document.getElementById("marketing").checked;
var academics=document.getElementById("academics").checked;

if(qual==true){
qual="Undergraduate";}
else{
qual="Graduate";}

if (it==true){
it="IT";}
else{
it="None";}

if (marketing==true){
marketing="Marketing";}
else{
marketing="None";}

if (academics==true){
academics="Academics";}
else{
academics="None";}

document.getElementById("info").innerHTML=
"Hello"+fullname<br>
"Your age is "+age" years"<br>
"Your qualification is" + qual<br>
"Your selected job types are"<br>
"Job 1 :" + it<br>
"Job 2 :" + marketing<br>
"Job 3 :" + academics<br>;
}
}
</script>
</HEAD>
<BODY>
<form name="job portal" action="">
<h1>Online Job Portal</h1>

<TABLE>
<tr>
<td>Name :</td>
<td><input type="text"
id="fullname"
name="fullname"
value=""></td>

</tr>
<tr>
<td>Age :</td>
<td><input type="text"
id="getage"
name="getage"
value=""></td>

</tr>
<tr>
<td>Qualification :</td>
<td>UnderGraduate<input type="radio"
name="qualification"
id="under"
value="undergraduate"></td>

<td>Graduate<input type="radio"
name="qualification"
id="grad"
value="graduate"></td>
</tr>
<tr> <td>Select a job type :</td>
<td>IT<input type="checkbox"
name="selectJobType"
id="it"
value="it"></td>
<td>Marketing<input type="checkbox"
name="selectJobType"
id="marketing"
value="marketing"></td>
<td>Academics<input type="checkbox"
name="selectJobType"
id="academics"
value="academics"></td>
</tr>
</TABLE>

<br>
<br>
<br>
<br>
<div id="info">
</div>



<input type="button"
value="Show Information"

onClick="checkForm()">

<input type="reset"
value="Reset Form">

</form>
</BODY>
</HTML>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic
skyward   HTML/JS help   Feb 16 2016, 02:16 AM
pandy   You seem to have a brace too many at the end of th...   Feb 16 2016, 05:29 AM
pandy   Oh, I changed to single quotes out of habit. It do...   Feb 16 2016, 05:58 AM
Christian J   The object is returned instead of the value for f...   Feb 16 2016, 05:58 AM
pandy   Duh. I just realized fullname was used in the stri...   Feb 16 2016, 06:04 AM
skyward   Duh. I just realized fullname was used in the str...   Feb 16 2016, 08:35 AM
Christian J   Could you post the corrected version as well?   Feb 16 2016, 08:46 AM
skyward   Could you post the corrected version as well? ...   Feb 16 2016, 08:51 AM
skyward   YAAAY Its running...only partially but running......   Feb 16 2016, 09:08 AM
pandy   It shouldn't make any difference in this case....   Feb 16 2016, 09:20 AM
Christian J   Try using your browser's script console, it sh...   Feb 16 2016, 09:34 AM
pandy   Here. [code]document.getElementById("info...   Feb 16 2016, 09:38 AM
pandy   Bummer. :blush:   Feb 16 2016, 09:39 AM
skyward   Bummer. :blush: DOOOOONNNNNEEEEE Happy to sa...   Feb 16 2016, 09:53 AM
pandy   Christian is always doing that. Lurks while I do a...   Feb 16 2016, 01:49 PM
Christian J   Usually it's pandy that posts first while I...   Feb 16 2016, 03:14 PM
pandy   No! Not the final solution. I often miss some ...   Feb 16 2016, 04:36 PM
skyward   No! Not the final solution. I often miss some...   Feb 17 2016, 12:58 AM
pandy   What do you mean by originally? The braces weren...   Feb 17 2016, 02:51 AM
skyward   What do you mean by originally? The braces weren...   Feb 17 2016, 07:51 AM
pandy   What do you mean by originally? The braces weren...   Feb 17 2016, 01:28 PM
Christian J   Christian, has FF removed the old JS console, or ...   Feb 17 2016, 03:57 PM
pandy   I don't get any of those things to show me JS ...   Feb 17 2016, 06:11 PM
Christian J   I don't get any of those things to show me JS...   Feb 17 2016, 07:03 PM
pandy   Click on the Console tab, and JS if necessary. Bu...   Feb 18 2016, 01:11 AM
pandy   FYI I don't find anything useful in Iron eithe...   Feb 18 2016, 01:17 AM
Christian J   Does Chrome have an error console? Yes. Since...   Feb 18 2016, 05:59 AM
pandy   Since there can be unique errors in a buggy brows...   Feb 18 2016, 07:55 AM
Christian J   Click on the Console tab, and JS if necessary. B...   Feb 18 2016, 05:53 AM
pandy   [quote name='pandy' post='115847' date='Feb 18 20...   Feb 18 2016, 07:54 AM
Christian J   No, I haven't installed any extensions. Fireb...   Feb 18 2016, 08:23 AM
pandy   Yes, all debuggers require reloading if they weren...   Feb 18 2016, 11:33 AM
pandy   Wait, it works now. I added a line break in the st...   Feb 18 2016, 11:37 AM
pandy   It does. Both tools, but they report just one erro...   Feb 18 2016, 11:58 AM
CharlesEF   It does. Both tools, but they report just one err...   Feb 18 2016, 12:25 PM
Christian J   My browser's script console didn't spot th...   Feb 17 2016, 08:40 AM
pandy   Yes, I think so. I didn't get an error for tha...   Feb 17 2016, 01:21 PM
CharlesEF   I use Firefox with Firebug installed also. It has...   Feb 17 2016, 08:20 PM
CharlesEF   If we are talking about the same thing then yes, i...   Feb 18 2016, 02:43 AM
pandy   If we are talking about the same thing then yes, ...   Feb 18 2016, 07:56 AM
pandy   If we are talking about the same thing then yes, ...   Feb 18 2016, 08:12 AM
Christian J   Didn't get far. Don't get any superscript...   Feb 18 2016, 08:24 AM
CharlesEF   Christian is correct. If you turn on Firebug afte...   Feb 18 2016, 11:08 AM
CharlesEF   FYI, according to the Firebug help forum all brows...   Feb 19 2016, 12:56 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 12:49 PM