473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

submit button isnt working

4
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.length;
if(n==0){
window.alert("enter 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 1728
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 100+
<input type="submit" onclick="valid()">
<script type="text/javascript">
<!--
function valid()
{
var n=document.form.fname.value.length;
if(n==0){
window.alert("enter 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 2GB
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.length;
if(n==0){
window.alert("enter 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 Expert 4TB
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 100+
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
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";...
15
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="..."...
15
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...
4
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...
10
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...
1
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. ...
10
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...
4
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...
10
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.