473,788 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cancelling the hyperlink navigation

14 New Member
Hi

I have a hyperlink in my form, and I am using:

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:myFunction('myTextBox','myFormName','ServletName')"> Go </a>

In my Javascript code, if all goes well, the form gets submitted and the page is forwarded to a servlet. If not, it should just alert the user and cancel the navigation.


Expand|Select|Wrap|Line Numbers
  1. if ((Fld.value.length==0) || (Fld.value==null) {
  2.         alert("Please Enter the information");
  3.         return false;  
  4.     }
  5.     else {
  6.  
  7.         //Submit form and go to servlet
  8.  
  9.     }

I have used the same code for a button and it works without problems. But since this is a hyperlink, instead of cancelling the navigation, I just get a Webpage with 'False' wirtten on top.

Is there a way to implement this with a hyperlink to work as appropriately as a button? I need to use hyperlinks according to design of some forms

Thank you for your help
Maral
Feb 28 '08 #1
2 2048
hsriat
1,654 Recognized Expert Top Contributor
Try this..[html]<a href="javascrip t:myFunction('m yTextBox','myFo rmName','Servle tName')" onclick="return validate()"> Go </a>[/html]If validation is done in myfunction(), then try to make a separate validate() function.
Feb 28 '08 #2
maralfarshadi
14 New Member
Try this..[html]<a href="javascrip t:myFunction('m yTextBox','myFo rmName','Servle tName')" onclick="return validate()"> Go </a>[/html]If validation is done in myfunction(), then try to make a separate validate() function.
Thank you very much for suggesting that.
Feb 29 '08 #3

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

Similar topics

7
4906
by: Randell D. | last post by:
Folks, I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can click on a text link which will then show the full record. I don't want to have hyperlinks with values incorporated in the link (thus, I don't want to have http://www.example.com?abc=1234) - I prefer to use a POST method thus what I would like to do...
0
1472
by: TheMan | last post by:
I am having trouble getting my HyperLink control to go to the desired navigation page. I have an image control on an ASP.NET page. When that image control is clicked it creates a HyperLink control with the respective properties, but it does not go to the desired page that I want. I do not know how to make the new HyperLink control execute so that it was as if the HyperLink was clicked. Here is the code: private void Image1_Click(object...
3
10942
by: Sandy Bremmer | last post by:
I was curious how one goes about properly creates a table row with multiple TD cells as a single hyperlink because I have seen examples of what I think is invalid and poorly conceived HTML. It works only in Internet Explorer (which is why I comment that I think it's poorly conceived because a navigation link limited to a specific browser is, well, stupid?). I have, for instance, seen where the "a href=..." tag begins outside the TR and...
4
4868
by: clintonG | last post by:
Any folklore regarding the benefits of using one or the other of these controls? <%= Clinton Gallagher METROmilwaukee (sm) "A Regional Information Service" NET csgallagher AT metromilwaukee.com URL http://metromilwaukee.com/ URL http://clintongallagher.metromilwaukee.com/
0
1290
by: Nathan Sokalski | last post by:
Whenever I assign a value to the HyperLink.NavigateUrl property, it adds an extra ../ in the generated href= attribute of the anchor tag. For example, when I assign it the value "comments.aspx" the href attribute comes out as href="../comments.aspx" The location of the file with the code that generates the anchor is in the root directory, while the aspx file is one level deeper. Could this be the problem? If it is, how can I fix it so that...
3
12364
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database? I would like to create a VB.net function that would do this, and I found this class *System.Web.UI.WebControls.HyperLink*, but I can not find any examples on generate a dynamic hyperlink. Basically, I want my function to generate an embedded...
3
2181
by: breakupemail | last post by:
Hello, on my website at http://www.breakupemail.com/ there is a horizontal navigation bar with 6 hyperlinks. Recently, I added a second navigation row below the first, with 2 links. Once this second navigation bar was added, the clickable area on the 6 links in the top row became greatly reduced when viewed in Firefox 2.0.0.9. It seems to work properly in IE 7. Essentially, if you hold your mouse over the center of the text link, it will...
1
1620
by: John Devlon | last post by:
Hi, I have a problem using a hyperlink and a frameset... When I run the application, and click on the link, the link is displayed in a new window... But the strange thing is, I set the target to the target frame.... using an html Very strang....
2
4705
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi, I am creating emails dynamically using C# and would like to place a hyperlink in the email body before sending it out. I added the text for what I thought was a hyperlink but the email just shows the entire text including the navigation URL where I would like it to show up as a clickable link but only display the portion of the hyperlink that it is supposed to. I am using microsoft Office 2007 and VS2005. Thanks. -- Paul G
0
9498
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
10370
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...
1
7519
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
6750
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
5402
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
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.