473,659 Members | 3,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple onclick=submit( ) need to pass name????

I have a number of applications where I want to have many
onclick='submit ()' attached to different 'elements' on a single form
..... which sends the form to a CGI "script" which does all the
validation. The problem is.. how can I code the submit()s so the CGI's
form collection knows which 'element' was clicked??

I am NOT permitted to use <input type=image...> or any "button" that
browsers produce for forms.... the reasons are all client related
;o)))

If I can put a string inside the parentheses (i.e.
onclick='submit ("thisbutton")' .... and have it's characters included in
the POST information to the CGI.. It will work for me. Can this be
done?? how?

Jul 23 '05 #1
11 10187
charlie_M wrote:
I have a number of applications where I want to have many
onclick='submit ()' attached to different 'elements' on a single form
..... which sends the form to a CGI "script" which does all the
validation. The problem is.. how can I code the submit()s so the CGI's
form collection knows which 'element' was clicked??

I am NOT permitted to use <input type=image...> or any "button" that
browsers produce for forms.... the reasons are all client related
;o)))

If I can put a string inside the parentheses (i.e.
onclick='submit ("thisbutton")' .... and have it's characters included in
the POST information to the CGI.. It will work for me. Can this be
done?? how?


onclick="someFu nction(this.id) "

<input type="text" name="inputUsed ">

function someFunction(in putID){
document.forms['formName'].elements['inputUsed'].value = inputID;
document.forms['formName'].submit();
}

And in each of your "elements" have an ID attribute that identifies it.

In other words, instead of using the element to submit the form, have
the element give a function its ID attribute, set a form field to that
value, then submit the form. Then, the server can pick up the value of
inputUsed to determine what element was used to submit the form.

And I won't go into the ludicrous idea of setting up a webpage the way
you are describing. If your client is that ignorant, its *your* job as
the professional to educate them on the pitfalls of the design.
Accessibility, non-JS, and many other issues make the entire approach a
bad design before you have ever started.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2
Lee
charlie_M said:

I have a number of applications where I want to have many
onclick='submi t()' attached to different 'elements' on a single form
.... which sends the form to a CGI "script" which does all the
validation. The problem is.. how can I code the submit()s so the CGI's
form collection knows which 'element' was clicked??

I am NOT permitted to use <input type=image...> or any "button" that
browsers produce for forms.... the reasons are all client related
;o)))

If I can put a string inside the parentheses (i.e.
onclick='submi t("thisbutton") '.... and have it's characters included in
the POST information to the CGI.. It will work for me. Can this be
done?? how?


1. It's your responsibility to point out to your clients that
they're making a potentially serious mistake by not allowing
the form to be submitted if Javascript is disabled.

2.
onclick="docume nt.forms[0].myHiddenField. value='thisButt on';document.fo rms[0].submit()"

Jul 23 '05 #3
OK.. 2 things I do not understand...

1. If I (as the CGI) receive an ID.. how do I know WHICH submit() it
was ?? Knowing that it was ID #5 tells me what??? This occured to me in
browsing other people's posts about this and similar topics. I need to
pass a NAME and somehow have it included in the form data return. The
CGI can then figure it out.

2. How do I get the form's data to be submitted with the form data and
the id(s)?? From your example. I think I see how this is done. Can
this be used more simply??? .... I only ever have 1 form... like???

function someFunction(Na meNotId){
thisform.elemen ts['NameNotId'].value = 'XX';
thisform.submit ();
}

I am only 'guessing' about the 'thisform' syntax..... does this work??

TIA
Chuck

Jul 23 '05 #4
You are right Lee.... and I have. These applications are very complex
and the client has a bug in his butt about looking a "paricular way"
and javascript must serve. The apps are written in Visual Fox and run
on a PC based blade server. We can not change how the server side works
and M$'s buttons and Netscape buttons are abhorent to the client, I am
attempting to get a <TD> to work as a submit button with appropriate
stylesheet colorings and rollovers. These are not public access apps...
they are for logged-in publishers and the ilk and we get to say how
they access the app!!!

Thanks
Chuck

Jul 23 '05 #5
charlie_M wrote:
OK.. 2 things I do not understand...

1. If I (as the CGI) receive an ID.. how do I know WHICH submit() it
was ?? Knowing that it was ID #5 tells me what??? This occured to me in
browsing other people's posts about this and similar topics. I need to
pass a NAME and somehow have it included in the form data return. The
CGI can then figure it out.
Pass the name itself.

<input type="button" name="button1" value="Button Number 1"
onclick="someFu nction(this.nam e)">

function someFunction(el emName){
myForm = document.forms['formName'];
myForm.elements['fieldName'].value = elemName;
myForm.submit() ;
}

Then, the server looks at the value of the field named "fieldName" and
it will know the name of the element that was clicked to submit the
form. Test it :)
2. How do I get the form's data to be submitted with the form data and
the id(s)?? From your example. I think I see how this is done. Can
this be used more simply??? .... I only ever have 1 form... like???

function someFunction(Na meNotId){
thisform.elemen ts['NameNotId'].value = 'XX';
thisform.submit ();
}

I am only 'guessing' about the 'thisform' syntax..... does this work??


Only in IE if the name of the form is thisform. See above.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #6
"charlie_M" <cm******@comca st.net> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com...
OK.. 2 things I do not understand...

1. If I (as the CGI) receive an ID.. how do I know WHICH submit() it
was ?? Knowing that it was ID #5 tells me what??? This occured to me
in
browsing other people's posts about this and similar topics. I need to
pass a NAME and somehow have it included in the form data return. The
CGI can then figure it out.


Don't rely on client-side JavaScript at all:

<%
Response.write( Request.value(' a1') + ';' + Request.value(' d1'));
%>
<form>
<input type="submit" name="a1" value="Add">
<input type="submit" name="d1" value="Delete">
</form>

If I click -a1- I get Add:null, if I click -d1- I get null;Delete.

It would be simple matter to loop on the server looking for a known
input name that has a non-null value, then act on it... for safety you
may want to pass another hidden input that contains the number
of -a#-, -d#- items, otherwise you wouldn't know when to stop checking
on the server.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #7
Grant..

I stated earlier I cannot change how the server side works. Also... I
cannot use any sort of BUTTON... i.e "<input type=submit...>

It would be a VERY simple matter to catch the value if it were
there.... but javascript.subm it() does not automatically provide it ..
which is why the "original" question was posed.......... .?????

The ANSWER.. BTW has been implimented and it works with some
limitations:

onClick="docume nt.forms[0].MYBUTTON.value ='FLASHW';docum ent.forms[0].submit()"

which requires I supply a hidden variable in the form named "MYBUTTON"
and my CGI will pickup on it if this submit() element is clicked.
BTW... this "element" is simply a <TD> with stylesheet rollover-type
elements..... and there are a number of them. This satisfies the
client, looks really impressive, works like a charm, was the answer to
the original question. ;o)))

Thanks to all that contributed...
Chuck

Jul 23 '05 #8
charlie_M wrote:
[...] M$'s buttons and Netscape buttons are abhorent to the client,
Then use input[type="image"] elements and create your own buttons.
I don't see a problem here, especially if it's not a "public app".
I am attempting to get a <TD> to work as a submit button with
appropriate stylesheet colorings and rollovers. [...]
Why not format an input[type="submit"] that way?
[...]
!!


Looks like you've lost something.
PointedEars
Jul 23 '05 #9


Thomas 'PointedEars' Lahn wrote:
charlie_M wrote:
[...] M$'s buttons and Netscape buttons are abhorent to the client,


Then use input[type="image"] elements and create your own buttons.
I don't see a problem here, especially if it's not a "public app".
I am attempting to get a <TD> to work as a submit button with
appropriate stylesheet colorings and rollovers. [...]


Why not format an input[type="submit"] that way?
[...]
!!


Looks like you've lost something.
PointedEars


I don't know why your ears are pointed.. but your eyes are failing you
;o))

REF: the original message says "I am NOT permitted to use <input
type=image...> or any "button" that browsers produce for forms.... the
reasons are all client related"... therefore: ??? The <TD> is what they
wanted... and I posted the solution.

Thanks
Chuck

Jul 23 '05 #10

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

Similar topics

2
17178
by: sandyde2 | last post by:
Hi all, I get the tough problem and expect to get help.. In a html page, I dynamically created many forms which named as NO+business_id. In each form there are two submit buttons to "release_or_not". of course in the server side I validate those values as well. However, because this page is for admin to use so that I do not need to care any hacker action. Hence, in the client side javascript I validate those values and give it a popup...
5
7713
by: José Carlos | last post by:
Hi. I am trying send a text value when click in an image. If i write: onClick="javascript:document.client.submit();" send all form, but i want to send only a input type text (name = cod), it´s possible? Thanks. Regards, José.
2
2760
by: J. B. Moreno | last post by:
Is it possible to detect inside an onsubmit event /which/ button was pushed? I searched google and saw lots of suggestions for alternatives, but nobody outright saying it was impossible. At this point I just want to know....I'll worry about compatibility and other issues, later... -- J.B.Moreno
5
2110
by: Lau Lei Cheong | last post by:
Hello, Let's say that I have multiple submit buttons on a form (imagebuttons actually, but documentations say that <input type=image> which a called image buttons should behave like submit buttons). How could I determine which submit button do I invoked by calling form.submit() in javascript? Thanks a lot. Regards,
1
2732
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine which values will be submited. Here is a simplified example that may better illustrate my question. Or maybe there is a better approach... <SCRIPT language="JavaScript">
2
2643
by: rudranee | last post by:
hello, How do i declare multiple submit buttons on a form? and how do i come to know on the next page which button has been clicked? Can i do it in JSP page? Please tell me.
7
15849
by: ChristinaTIT | last post by:
Hi, I have a form containing ID Type Quantity Rate values. it should have two submit buttons which, when posted, will do the two different things in two different scripts.
7
4387
by: aashishn86 | last post by:
hi ! how can i use multiple submit buttons in the same form i want to pass form values to different pages depending on which of the two submit button is clicked... thank's
3
4012
by: printline | last post by:
Hello All I have a form with multiple submit buttons, where i would like to open in a new window when hitting one of the submit buttons. Can't seem to figure this out according to the code i'm using. Could someone perhaps tell me what to do...??? Here is the code i'm using: <SCRIPT> function submitFunction(i) { if (i==1) document.shopform.action="http://www.printline.dk/webshop/upload.php"; if (i==2)...
0
8428
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
8337
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
8851
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
8531
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,...
0
7359
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...
0
5650
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
4175
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...
1
2754
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
1739
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.