473,785 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please hepl

1 New Member
I have been teaching myself javascript and i am having a huge problem with this form. All it has to do is check that every field has something in it and then post, but as soon as it gets to the document.getEle mentById('form1 ').submit(); it throws an error and say that the object is not supported. Here is the code:

<script language="javas cript">
function check_form(){

if(document.get ElementById('na me').value == ""){
alert("Enter in your name:");
document.getEle mentById('name' ).focus();
return;
}

if(document.get ElementById('su rname').value == ""){
alert("Enter in your surname:");
document.getEle mentById('surna me').focus();
return;
}


if(document.get ElementById('em ail').value == ""){
alert("Enter in your Email Address:");
document.getEle mentById('email ').focus();
return;
}

if(document.get ElementById('bn ame').value == ""){
alert("Enter in your business name:");
document.getEle mentById('bname ').focus();
return;
}

if(document.get ElementById('ce llno').value == ""){
alert("Enter in your Cellphone number:");
document.getEle mentById('celln o').focus();
return;
}


if(document.get ElementById('Q1 ').value == ""){
alert("Please answer Question 1:");
document.getEle mentById('Q1'). focus();
return;
}

if(document.get ElementById('Q2 ').value == ""){
alert("Please answer Question 2:");
document.getEle mentById('Q2'). focus();
return;
}

if(document.get ElementById('Q3 ').value == ""){
alert("Please answer Question 3:");
document.getEle mentById('Q3'). focus();
return;
}

document.getEle mentById('form1 ').submit();
}

</script>

<table>
<form name="form1" id="form1" action="mailer2 .php" method="post">
<tr>
<td colspan="3"><st rong>Customer Details</strong></td>
</tr>
<tr>
<td colspan="3">Ple ase fill in the following * textboxes in order to press submit.</td>
</tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr>
<td >*&nbsp;&nbsp;& nbsp;Name:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="name" id="name" type="text" /></td>
</tr>
<tr>
<td >*&nbsp;&nbsp;& nbsp;Surname:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="surname" id="surname" type="text" /></td>
</tr>
<tr>
<td >*&nbsp;&nbsp;& nbsp;Email:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="email" id="email" type="text" /></td>
</tr>
<tr>
<td >*&nbsp;&nbsp;& nbsp;Business Name:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="bname" id="bname" type="text" /></td>
</tr>
<tr>
<td >&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;Ticket Number:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="ticno" id="ticno" type="text" /></td>
</tr>
<tr>
<td >&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;Telephone Number:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="telno" id="telno" type="text" /></td>
</tr>
<tr>
<td >*&nbsp;&nbsp;& nbsp;Cellphone Number:</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</td>
<td><input name="cellno" id="cellno" type="text" /></td>
</tr>
<tr><td colspan="3">&nb sp;</td></tr>
<tr><td colspan="3">&nb sp;</td></tr>
<tr>
<td colspan="3"><st rong>Questionai r</strong></td>
</tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr>
<td >1. Were you treated in a friendly manner?</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp; </td>
<td >
<input name="Q1" id="Q1" value="poor" type="radio" />Poor
<input name="Q1" id="Q1" value="average "type="radi o" />Average
<input name="Q1" id="Q1" value="good" type="radio" />Good
</td>
</tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr>
<td >2. Was your query attended to quickly and efficiently ?</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp; </td>
<td >
<input name="Q2" id="Q2" value="poor" type="radio" />Poor
<input name="Q2" id="Q2" value="average" type="radio" />Average
<input name="Q2" id="Q2" value="good" type="radio" />Good
</td>
</tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr>
<td >3. Has your query been resolved?</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp; </td>
<td >
<input name="Q3" id="Q3" value="poor" type="radio" />Poor
<input name="Q3" id="Q3" value="average" type="radio" />Average
<input name="Q3" id="Q3" value="good" type="radio" />Good
</td>
</tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr>
<td >4. Do you have any suggestions to improve our service?</td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp; </td>
<td >
<textarea cols="25" rows="3" name="Q4" id="Q4"></textarea>
</td>
</tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr>
<td >5. Would you like to hear about Webstorms:</td>
<td align="right" >3G&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;</td>
<td >
<input name="check1" id="check1" value="yes" type="radio" >
</td>
</tr>
<tr>
<td align="right" colspan="2" >ADSL&nbsp;&nbs p;&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;</td>
<td >
<input name="check2" id="check2" value="yes" type="radio" >
</td>
</tr>
<tr>
<td align="right" colspan="2" >Wireless&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp; </td>
<td >
<input name="check3" id="check3" value="yes" type="radio" >
</td>
</tr>
<tr>
<td align="right" colspan="2" >I-burst&nbsp;&nbs p;&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;</td>
<td >
<input name="check4" id="check4" value="yes" type="radio" >
</td>
</tr>
<tr>
<td align="right" colspan="2" >Hosting&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;&nbsp;& nbsp;&nbsp;</td>
<td >
<input name="check5" id="check5" value="yes" type="radio" >
</td>
</tr>
<tr>
<td align="right" colspan="2">Web design&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;</td>
<td>
<input name="check6" id="check6" value="yes" type="radio" >
</td>
</tr>
<tr><td colspan="3">&nb sp;</td></tr>
<tr>
<td colspan="3"><hr color="#CCCCCC" width="660" align="center" /></td>
</tr>
<tr><td colspan="3">&nb sp;</td></tr>
<tr>
<td align="right">< input type="button" value="Submit >>" id="submit" name="submit" onclick="check_ form();" /></td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;</td>
<td align="left">
<input type="button" value="Reset <<" id="reset" name="reset" /></td>
</tr>
</form>
</table>

It is posting through a PHP page, and its not throwing any errors on that page.

If anyone could help i would be truely grateful.

Tyla
Sep 21 '06 #1
2 1695
r035198x
13,262 MVP
Did not really study your code but I do not see why you are going through the
trouble of using document.getEle mentById, when the form is being passed from which you can get the input name. Also since the validation is basically the same for all the input boxes, perhaps you do not even have to pass the names of the inputs
Sep 21 '06 #2
ronverdonk
4,258 Recognized Expert Specialist
I am not sure about the ins and outs of the GetElementById. submit(), but have you tried
[PHP]document.form1. submit();[/PHP]
Ronald :cool:
Sep 21 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2170
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import javax.swing.JApplet; import javax.swing.JOptionPane; import java.awt.Graphics;
2
2380
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta http-equiv="Content-Type" content="text/html;
7
3615
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
4
3521
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this Fixpack on a test machine running ESE but encountered a serious error during the install. It started 'copying new files' but then stopped cold and displayed a dialog box asking me to "Please insert disk 1". (It all fit on one CD!) I clicked OK...
5
2657
by: Dmitry Bond. | last post by:
Hello. Our product works fine on all 7.x and 8.x DB2 versions. But stops to work on DB2 v9.1. The main problem is - duplicate primary key (sqlcode=-803) happens when inserting records in QUEUE table. The primary key of QUEUE table is - 3 fields - QID CHAR(4), PRI INT and QTIME TIMESTAMP. When inserting records into QTIME table we are using the "CURRENT
1
54537
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
2
1237
by: ladislav | last post by:
I have error in System.out.println(firstprime.findPrime ()); I don't know how it repair.Please hepl me with it. ** *PrimeNumber.java * * * * To change this template, choose Tools | Template Manager
2
10500
by: keethyanandpr | last post by:
Hi, This is the error I get when I try to download a file from Rapidshare. ERROR: Please enable JavaScript. I uninstalled and reinstalled Sun JDK 6.0. Sill the problem persists. The problem is generic now. For instance I cannot use the collapse / expnad links at the top of this post. I have also enabled all scritping options in my browser (IE 7.0).
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.