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

Home Posts Topics Members FAQ

onsubmit two functions

oll3i
679 Contributor
I want to call two functions on submit
onsubmit="retur n checkTitle(this ,'<? echo $language?>');s etOfferCookies( )"
but it doesnt even call the first function

Expand|Select|Wrap|Line Numbers
  1. function checkTitle(form,language){    
  2.     alert("checkTitle");<----to check if it works
  3.     if(form.title.value.length==0 || form.title.value=="***Proszę wpisać tytuł!" ||  form.title.value=="***Please enter the title!" ){
  4.         document.getElementById("title").style.color="red";
  5.         if(language=="polish"){        
  6.         form.title.value="***Proszę wpisać tytuł!";}         
  7.         else {form.title.value="***Please enter the title!";}
  8. return  false;
  9. }else {document.getElementById("title").style.color="black";}
  10. return true;
  11. }
  12.  
thank You
Mar 7 '08 #1
10 4060
hsriat
1,654 Recognized Expert Top Contributor
I want to call two functions on submit
onsubmit="retur n checkTitle(this ,'<? echo $language?>');s etOfferCookies( )"
When you had already returned, second function could never execute.

Try this...
Expand|Select|Wrap|Line Numbers
  1. onsubmit="setOfferCookies(); return checkTitle(this,'<? echo $language?>');"
Mar 7 '08 #2
oll3i
679 Contributor
but i dont want this second function to execute when the first function returns false
the problem is that the first function doesnt execute
that's why i added the alert box to see if it executes and the alert box doesnt show?
Mar 7 '08 #3
hsriat
1,654 Recognized Expert Top Contributor
As far as the first function is concerned, I remember you asked this earlier too.
Wasn't that solved that time?
Mar 7 '08 #4
hsriat
1,654 Recognized Expert Top Contributor
but i dont want this second function to execute when the first function returns false
the problem is that the first function doesnt execute
that's why i added the alert box to see if it executes and the alert box doesnt show?
The way use have used it, it won't get executed even if the first function returns true.
For that, use this:
Expand|Select|Wrap|Line Numbers
  1. onsubmit="if (checkTitle(this,'<? echo $language?>')) { setOfferCookies(); return true;} else {return false;}"
Mar 7 '08 #5
oll3i
679 Contributor
thank you
the problem with the first function is that it doesnt even execute
Mar 7 '08 #6
hsriat
1,654 Recognized Expert Top Contributor
thank you
the problem with the first function is that it doesnt even execute
Can you show me the source (the one you get when you click on view source) of your page that displays the form and the above function.
Mar 7 '08 #7
oll3i
679 Contributor
<form name="editor" action="save.ph p?language=poli sh" onsubmit="if (checkTitle(thi s,'polish')) { setOfferCookies (); return true;} else {return false;}">
<table width="720" border="0" cellspacing="0" cellpadding="2" >
<tr>
<td width="180">
<span id="profile_fon t_weight">
Tytuł*
</span>
</td>
<td>
<input type="text" size="101" name="title" id="title">
</td>
</tr>

js is included in the head
Mar 7 '08 #8
hsriat
1,654 Recognized Expert Top Contributor
[html]<script>
function checkTitle(form ,language) {
alert("checkTit le");//<----to check if it works
if (form.title.val ue.length==0 || form.title.valu e=="***Prosze wpisac tytul!" || form.title.valu e=="***Please enter the title!" ) {
document.getEle mentById("title ").style.color= "red";
if(language=="p olish") form.title.valu e="***Prosze wpisac tytul!";
else form.title.valu e="***Please enter the title!";
return false;
}
else {
document.getEle mentById("title ").style.color= "black";
}
return true;
}
</script>
<form name="editor" action="save.ph p?language=poli sh" onsubmit="if (checkTitle(thi s,'polish')) { setOfferCookies (); return true;} else {return false;}">
<table width="720" border="0" cellspacing="0" cellpadding="2" >
<tr>
<td width="180">
<span id="profile_fon t_weight">
Tytul*
</span>
</td>
<td>
<input type="text" size="101" name="title" id="title">
<!--just added the submit button-->
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>[/html]I tried this, and it worked.
There's nothing wrong with the JavaScript code.
Mar 8 '08 #9
oll3i
679 Contributor
You wont believe it i forgot to end the form hihi now it works
Mar 8 '08 #10

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

Similar topics

4
18691
by: Stuart Wexler | last post by:
Hi, I have a form with onSubmit embedded in the <form> tag. The form is submitted programatically through javascript . While the form submits fine, nothing I'm doing seems to get it to also register the code in the onSubmit event. Any suggestions as to why this is happening or how to resolve it? -Stu
3
1803
by: CharitiesOnline.co.uk | last post by:
Can anyone tell me, what is the maximum functions that you can call using a form submit button with onSubmit ? I am using 2 at present but really need to use 3 , how can I do this? Thanks Joe.
4
2735
by: Kai Grossjohann | last post by:
I have two frames. Frame "search" contains a search form specifying an onsubmit action like so: <form ... onsubmit="foo();"> ... </form> The other frame contains a <img ... onclick="perform_search();"> where the perform_search function is defined as follows:
3
12154
by: n3mtkj3mzsir0cy | last post by:
I have created web pages that do client-side form validation using the onclick directive. E.g., <form action=other_page.cgi method=post> Enter your age: <input name=age> <input type="submit" value="" onclick="return validate_form()"> </form> where validate_form() returns true or false depending on whether the user entered a valid age.
2
6471
by: Sean Dockery | last post by:
Which is the following is correct? a) <form ... onSubmit="return checkData()"> b) <form ... onSubmit="return checkData();"> c) <form ... onSubmit="checkData()"> d) <form ... onSubmit="checkData();">
4
10147
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
8
6850
by: Mark Livingstone | last post by:
I have a form that uses the following: onSubmit="some_var = 'validated';" FireFox is OK with that. Internet Explorer isn't. any ideas why? Thanks.
1
1944
by: vunet | last post by:
I write a JS library component which is applied to every form on a webpage. The component does something before it submits the form. Now, let's say user has his own onSubmit() handlers returning true or false. I want to find a way to add my component's "onsubmit" event to the form without overwriting user-defined onSubmit() handlers or onsubmit events. Is there a really good way of doing this? The problem I've come across was if I add...
2
4776
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as I will. Let me illustrate the problem with examples. The HTML: <html> <head> <script type="text/javascript" src="/js/mootools_1_11.js"></script>
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
10327
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
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
10092
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 most users, this new feature is actually very convenient. If you want to control the update process,...
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
5381
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
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.