473,805 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onClick submitForm()

I need to submit a form using a hyperlink, and I need to pass a
variable associated with that hyperlink.

Example: I have a page where employees enter event information, and
they are supplied a dropdown box to pick the promoter for that event.
If the promoter does not exist in the database, they need to add
him/her to the database so that the promoter can be associated with
the event. If the promoter does not exist, I want to provide a link
(Add Promoter), that will submit the form, and pass a variable to the
query page, either in the form scope or url scope, that is
"mode=addPromot er", so that I can take them immediately send them to
the promoters page, and then I will take them back to the event page
to fill in the rest of the information.

So, in a nutshell, I need to submit a form using a hyperlink, and to
also pass a variable in either the url scope or form scope.

Any help is greatly appreciated.
Jul 20 '05
14 28143
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
Lasse Reichstein Nielsen wrote:
> If the browser supports javascript, then the onclick will work. If
> not, the href won't work either. That is, there is almost never
> any need for a javascript:-URI.

Please note that event handlers are standardized, `javascript:' URIs are
not. The latter is `common practice' anyway, so the above combination has
a 100% chance to work if client-side JavaScript is supported and enabled.
Do you know of *one* browser where the javascript:-URI works and the
onclick attribute doesn't?


No, but that is irrelevant.
If there isn't one,


Although I (or you) don't know one, there may be one.


There might also be one that requires the Javascript in the URI to be
spelled backwards. I don't think that is likely, so I don't spell my
javascript backwards. Likewise, I think it is extremely unlikely that
there is a browser that understands Javascript and javascript:-URIs,
but doesn't understand the onclick handler.

If you have nothing else to put in the HREF then (it is a good sign
you are using the wrong element, but) you might just as well put the
URI there. I would prefer a href that made just the tiniest amount
of sense when Javascript is disabled. Like a link to a page that
explains what should have happened if Javascript was enabled.

After all, the hypothetical browser that might use the URI isn't as
important a user group as the 10% without Javascript.
there is no need for the URI, since it will only ever be used by
non-javascript browsers.


You don't get the point.


Sure I do, I just disagree :)
UAs that don't know the event handler
That is: UAs that don't know HTML 4.
will ignore it and access the URI,
.... but will fail again if it doesn't understand or support
Javascript.
OK, maybe I made myself not clear enough: The hyperlink to an alternative
document that is accessed when JavaScript support is not available, is in
*this* case complete nonsense since the form data provided (namely the
promoter's name to add) is then lost.
Yes. That suggests a bad design, since the problem wouldn't be a problem if
a submit button was used.
You mean they know then that the webauthor is incompetent
enough not to foresee that certain possibility. Great.
Exactly :)
You played the devil's advocate again? ;-)


I wouldn't call it that. Just deliberatly thought provoking :)
That is a solution. If the link is vital to the page, the entire
page can be written that way.


No, that would be definitely a Bad Thing unless users without JavaScript
don't get there in the first place, i.e. it is not even listed in search
engines. But you then can disregard users without JavaScript anyway and
the time-consuming and sometimes hard-to-read DOM scripting is no longer
required.


Exactly. :) A page that doesn't work without Javascript should not be
reached unless Javascript is available.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Demo: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #11
I'm happy to see you both used my question as an opportunity to argue
your beliefs in what should/should not be used in web development.

Neither one of you really answered my question, nor gave me a solid
solution to what I wanted to accomplish. Just so that you know,
although it is irrelevant, the application I have developed has close to
1000 pages of coldfusion/sql server 2000 code, both of which platforms I
could probably run circles around your knowledge. I completely control
all aspects of the environment, including the fact that we use IE 6 for
web development (which you both argued about usability). I wanted to
use a hyperlink to submit a form, and at the same time, pass a variable.
I wasn't looking for advice, I was looking for an answer. Luckily I
found the answer elsewhere, and will not be coming back here for help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #12
On 31 Oct 2003 04:00:33 +0100, Lasse Reichstein Nielsen
<lr*@hotpop.com > wrote:
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
> there is no need for the URI, since it will only ever be used by
> non-javascript browsers.


You don't get the point.


The more important reason to not use javascript: is that it's
non-standard, and not even supported by as many user agents as support
onclick in A, also the failure scenarios even in script enabled pages
are severe with some browsers (such as IE) navigating the user to its
generic "page not found page".

There's also the problem of "open in new window" which is commonly
used by people on links, with the example in the thread, even in UA's
that can otherwise execute the script will result in the script
executing in the context of the new window.
Exactly. :) A page that doesn't work without Javascript should not be
reached unless Javascript is available.


Which is completely impossible to proof that it's available, so even
in such pages gross level protection (like a link which does not cause
errors, and does not do anything strange - but does not function as
expected ie loses the information from the form.)

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #13
On 31 Oct 2003 06:01:20 GMT, Erik H <de***********@ bigdummy.com>
wrote:
both of which platforms I could probably run circles around your
knowledge.
Do you really think it's likely to get your question answered quicker
if you come in and deride the knowledge of two people who have shown
they know they're javascript - I expect you could run circles around
their knowledge of some completely unrelated language to the
newsgroup, but it's neither relevant or useful.
I completely control
all aspects of the environment, including the fact that we use IE 6 for
web development (which you both argued about usability).
Good to see you have a good upgrade strategy in place for dealing with
the next version of the browser.
I wasn't looking for advice, I was looking for an answer.


Paid support forums are elsewhere, this is a newsgroup, all you get is
advice.

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #14
Jim Ley wrote:
Exactly. :) A page that doesn't work without Javascript should not be
reached unless Javascript is available.


Which is completely impossible to proof that it's available, so even
in such pages gross level protection (like a link which does not cause
errors, and does not do anything strange - but does not function as
expected ie loses the information from the form.)

Jim.


Or simply use something like:

<style type="text/css">
input.submitBtn {
background-color: transparent;
border: none;
text-decoration: underline;
color: blue;
cursor: pointer;
cursor: hand;
}
</style>
<form>
<input type="submit" id="submitId" name="submitNam e" value="Click here"
class="submitBt n" />
</form>

and then you don't need to worry about whether client-side JavaScript is
enabled or not, you get the same behaviour regardless of the client-side
JavaScript capabilities of the UA.

By the way, Opera 7.21 appears to not understand "text-decoration:
underline;" nor does it understand the "cursor: " designations. Also,
Opera 7.21 does not properly render "border: none;". The last problem can
be dealt with by specifying:
"border: 0px solid transparent;" (well, actually the color doesn't
matter), but I'm not sure how standard a border-width of 0px is.

Also note that "border: 1px solid transparent;" works in all browsers
except IE6, where it appears that the "color: " bleeds through the
"transparen t" border and you get a blue border 1px wide.

There are a very few minor problems with this approach, one is that the
color of the text on the button does not change to that of a followed
link, the other is that the "link" exhibits the behaviour of a button,
with the text shifting down and to the right when clicked. This may or may
not present a problem for your target audience.

Anyway, I'd probably rather live with the possibility that my button will
not *appear* exactly as I intended it on all browsers, as long as it
*functions* the way I intend on those same browsers. In other words, if
Netscape 4 users get a big ugly grey button, that's *their* problem, as
long as they can still get their information to me if they have JavaScript
disabled.

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3690
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function and passes it two parameters. For the life of me I cannot figure out what the error is, but one occurs everytime I click a &%*$&# radio button. Also, the function only alerts the user immediately as to what question/answer they clicked. I am...
17
61449
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to programmatically issue a JavaScript statement which causes the browser to act just like the user clicked on a link in my page. And if that link has an onClick JS event defined, I'd want that onClick event to execute too, exactly the same as if the user...
2
9185
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display in the status bar 'Symantec Corporation' whenever anyone mouses over (onMouseOver) my image or link OR when one clicks while holding the left mouse down (onClick) on the same image or link. Upon releasing the mouse (onMouseOut), the
3
3272
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement "return promptBeforeOpening();" FF and IE rewrite it as I would expect them to, but it turns out that that doesn't work (no disclaimer pops up, and the link is not disabled):
2
18585
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } Which is called statically by: <button onclick="doClick(event,this);">Click me</button>
2
3294
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for its onclick event. it's something like: <input type="submit" name="Button1" value="Button" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="Button1" /> what i want to do is to be able to...
6
7176
by: Nx | last post by:
i've got it all working nicely in firefox, but whenever i test it in IE none of the onclick events are triggered. i'm using an xsl to transform an rss feed into a photogallery. when i try to use setAttribute FF and safari work, but IE stops working when i used addEventListener and attachEvent safari stops working and when i tried .onClick,none of them worked being fairly inexperienced (but learning fast), i figure i'm doing it
7
2797
by: extremerep | last post by:
My task is to change the value of a button and then make it functional with the onClick handler. Changing the value to "Play Again" works, but making the onClick work accordingly does not. The following is a snippet of the script. What is keeping it from working? function displaycards1(){ document.form1.reveal1.value="Play Again"; document.form1.reveal1.onClick="setcards();"; } </script>
9
7149
by: poml | last post by:
Hello, first time posting on thescripts.com, and I'm in dire need of some help. All I want to do is disable the submit button (not the entire form) onClick, and am wondering if this is possible. Here's the current coding: <form enctype="multipart/form-data" action="?id=completeupload" name="submitform" method="POST"> <b>File to Upload:</b>&nbsp;<input name="userfile" size="50" type="file"><br><br> <span class="class3"> <input...
0
9718
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
10363
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...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
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
5544
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
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
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.