473,587 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

submit button isnt working

4 New Member
am doing my first project so plz help
i've created a submit button
[HTML]<input type="submit" onclick="valid( )">[/HTML]
my function valid checks if the fields are not empty if empty a window prmpt appears then when i press ok i move to the next page
for example
[HTML]<script type="text/javascript">
<!--
function valid()
{
var n=document.form .fname.value.le ngth;
if(n==0){
window.alert("e nter ur first name");
return false;
} }
//--></script>
[/HTML]then the php code
[HTML] <input type="submit" name="sub" value="Submit Your Entries" onclick="valid( )" />
[/HTML]i wrote instead of type="submit" =>type="button " it works but when i fill all the fields am not moving to next page
Oct 5 '07 #1
5 1743
FullyH3ktik
52 New Member
what if you added this to your function:
Expand|Select|Wrap|Line Numbers
  1. else
  2. {
  3. location.href="URL goes here";
  4. }
that way if the field is not blank, it will take you to the page specified.
Oct 5 '07 #2
ajos
283 Contributor
<input type="submit" onclick="valid( )">
<script type="text/javascript">
<!--
function valid()
{
var n=document.form .fname.value.le ngth;
if(n==0){
window.alert("e nter ur first name");
return false;
} }
//--></script>
hi soheir,
why are you using <!-- --> ? you are commenting the function that needs to be called...plz remove the comments...
regards,
ajos
Oct 5 '07 #3
dmjpro
2,476 Top Contributor
am doing my first project so plz help
i've created a submit button
<input type="submit" onclick="valid( )">
my function valid checks if the fields are not empty if empty a window prmpt appears then when i press ok i move to the next page
for example
<script type="text/javascript">
<!--
function valid()
{
var n=document.form .fname.value.le ngth;
if(n==0){
window.alert("e nter ur first name");
return false;
} }
//--></script>
then the php code
<input type="submit" name="sub" value="Submit Your Entries" onclick="valid( )" />
i wrote instead of type="submit" =>type="button " it works but when i fill all the fields am not moving to next page

Use code Tags buddy :-)
Please read the posting guidelines before you post.

Have a look at this ....

Expand|Select|Wrap|Line Numbers
  1. <form onsubmit = "return valid();">
  2. .
  3. .
  4. </form>
  5.  
Expand|Select|Wrap|Line Numbers
  1. function valid()
  2. {
  3.  return (condition_satisfies);
  4. }
  5.  
Debasis Jana
Oct 5 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, ajos.

why are you using <!-- --> ? you are commenting the function that needs to be called...plz remove the comments...
The code is not actually commented. It's an old trick to prevent *really* older browsers (does anyone use a browser that doesn't know what JavaScript is anymore?) from displaying JavaScript code on the web page. But all modern browsers know that the code isn't *really* commented.

Nowadays, the bigger concern is XML compatibility. That's why you often see:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. // ]]>
  4. </script>
  5.  
Oct 5 '07 #5
ajos
283 Contributor
Heya, ajos.
The code is not actually commented. It's an old trick to prevent *really* older browsers (does anyone use a browser that doesn't know what JavaScript is anymore?) from displaying JavaScript code on the web page. But all modern browsers know that the code isn't *really* commented.

Nowadays, the bigger concern is XML compatibility. That's why you often see:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. // ]]>
  4. </script>
  5.  
hey pbmods,
thanks for correcting me regarding this, i got stumped by seeing <!-- --> this in the first place(not common to see actually).:-)
this forum is great...keep up the good work friends!!!
regards,
ajos
Oct 5 '07 #6

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

Similar topics

5
3678
by: Bruce Duncan | last post by:
I can't seem to figure our why this doesn't work. I don't get any errors, it just doesn't submit. Can anyone shed some light. <?PHP $var1 = "http://localhost/php/index.php"; $varx = "bruce"; echo "<form name='formx3' method='post'><input type='text'><input type=button value=go onclick=document.formx3.action='".$var1."';...
15
28934
by: Mattia | last post by:
Hi! I have a <form> that can be submitted thruogh three buttons and I need to tell witch one was pressed when the form was submitted. I now do it with 3 <input type="submit" name="..." value="..."> with <input type="submit" ...> the only name-value values submitted (pushed into the query string) is the one of the submit button that was...
15
2542
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A Column B Column C data 4 radio buttons more data .... ... ...
4
5580
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer postback. I.e. the button does go disabled, but the form does not invoke submit() method. Of course, it does work fine without this property. Clues?
10
3026
by: Perry van Kuppeveld | last post by:
Hi, I have a problem with formatting a table including text fields wich can contain up to 255 chars. I need a table with 3 columns: - First column 50 % over the with a rowspan of the total number of rows. - Second column 25 %, no rowspan - Third column 25 %, no rowspan
1
1844
by: Sarmatia | last post by:
I had a page working. The user moves data around the page - to and from different ListBoxes and could save the changes with a click of a button. Sounds easy, but *that's* a whole other nightmare. Nevertheless, it was working. The Submit button was an asp:button with an OnClick server-side method. Easy-cheesy. Enter in-house standards. ...
10
6068
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get different results than when I use a javascript submit: form1.submit();. I think the javascript submit is working as it should, since I want the...
4
6664
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all I have the following code: I am trying to use the value of the image button to evaluate what plan the user has chosen, i.e. it request("submit1")="Basic", then the user chose basic plan ... But when I click one of the image button, the thing is different from what I thought. it seems that it has field name like...
10
8588
by: The Natural Philosopher | last post by:
I am coding up a bit of javascript stuff, and have managed to stumble my way through most of what I want.. But this one has got me stumped. I call submit() and get a javascript error 'Submit not defined' in Firefox.. My very expensive javascript Bible assures me its built in ..so where oh where have I FSCKED up?
0
7918
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...
0
7843
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...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5713
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...
0
5392
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...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2353
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
0
1185
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...

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.