473,320 Members | 1,920 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,320 software developers and data experts.

submitting form through javascript

Hi all
I have a page which contains a form.
I want a customized button with an image for the submit button, and when the
submit button has been clicked send the form to the perl script.
Now the form is no problem but the button is, so the question is how do I
create a custom button and how do I submit the form with javascript when the
button is clicked?
many thank's for any hint and help
B
Jul 20 '05 #1
15 3490

"Bob Smith" <bo*********@hotmail.com> schreef in bericht
news:85*****************@reader1.news.jippii.net.. .
Hi all
I have a page which contains a form.
I want a customized button with an image for the submit button, and when the submit button has been clicked send the form to the perl script.
Now the form is no problem but the button is, so the question is how do I
create a custom button and how do I submit the form with javascript when the button is clicked?
many thank's for any hint and help
B


Hi

Why use javascript? <input type=image> does what you want

http://msdn.microsoft.com/library/de...nput_image.asp

Fred
Jul 20 '05 #2
> >

Hi

Why use javascript? <input type=image> does what you want thank's
but it doesn't work as expected,
the form is not submitted
( browser netscape 4.7x)
any help much appreciated.
B

http://msdn.microsoft.com/library/de...thor/dhtml/ref
erence/objects/input_image.asp
Fred

Jul 20 '05 #3
"Bob Smith" <bo*********@hotmail.com> wrote in
news:y6*****************@reader1.news.jippii.net:
>


Hi

Why use javascript? <input type=image> does what you want

thank's
but it doesn't work as expected,
the form is not submitted
( browser netscape 4.7x)
any help much appreciated.
B


dude, seriously. The following two are equivalent:

<input type="image" src="some_image.gif" name="submit" />
<input type="submit" name="submit.x" />

they will both submit the form.. I would hazard to guess this even works on
Netscape 2.0. Of course .. you need an actual GIF to make the button.
--
In theory there is no difference between theory and practice. In practice
there is. - YB
Jul 20 '05 #4
"Bob Smith" <bo*********@hotmail.com> wrote in message news:<85*****************@reader1.news.jippii.net> ...
Hi all
I have a page which contains a form.
I want a customized button with an image for the submit button, and when the
submit button has been clicked send the form to the perl script.
Now the form is no problem but the button is, so the question is how do I
create a custom button and how do I submit the form with javascript when the
button is clicked?
many thank's for any hint and help
B

Bob,

You want something like:

<form method="post" action="myperl.script">
<button onClick="document.forms[0].submit()">
<img src="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
width="250" height="60">
</button>
</form>

It is possible that images inside buttons are Internet Explorer only,
not sure.

Regards
Bart
Jul 20 '05 #5
"Bart Van der Donck" <ba**@nijlen.com> wrote in message
news:b5**************************@posting.google.c om...
<snip>

You want something like:

<form method="post" action="myperl.script">
<button onClick="document.forms[0].submit()">
<img src="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
width="250" height="60">
</button>
</form>
No you don't. As the desired effect can be achieved with pure HTML that
is how it should be achieved, but the default type of a BUTTON element
is "submit" anyway so even this option would work as pure HTML if you
take the JavaScript onclick attribute out.
It is possible that images inside buttons are Internet Explorer only,
not sure.


Netscape 4 does not recognise the BUTTON element at all (because it was
introduced with HTML 4) but I think that images are OK as content
everywhere that BUTTON is recognised (though ALT text becomes very
relevant in speech/text browsers (and is required on IMG elements in
HTML 4 anyway)).

Richard.
Jul 20 '05 #6
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote...
You want something like:

<form method="post" action="myperl.script">
<button onClick="document.forms[0].submit()">
<img src="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
width="250" height="60">
</button>
</form>


No you don't. As the desired effect can be achieved with pure HTML that
is how it should be achieved, but the default type of a BUTTON element
is "submit" anyway so even this option would work as pure HTML if you
take the JavaScript onclick attribute out.


<button type="submit"> would work too, yes. It are just 2 ways to
achieve the same goal. Is that why Bob shouldn't use my code ?
However, by just taking the onClick event away, the form doesn't
submit (just quick test on IE6 here) as you say.

It is possible that images inside buttons are Internet Explorer only,
not sure.


Netscape 4 does not recognise the BUTTON element at all (because it was
introduced with HTML 4) but I think that images are OK as content
everywhere that BUTTON is recognised (though ALT text becomes very
relevant in speech/text browsers (and is required on IMG elements in
HTML 4 anyway)).


Is ALT required on IMG elements in HTML4 ? No it is not.
About speech/text browsers: yes of course in those cases it is
relevant, or relevant as info for surfers, or when download fails or
....etc

I never met a textbrowser in my logs however. Not sure about speech
browsers, but, fairly, I would be surprised.

Bart
Jul 20 '05 #7
In article <b5*************************@posting.google.com> , ba**@nijlen.com
(Bart Van der Donck) writes:
Is ALT required on IMG elements in HTML4 ? No it is not.


HTML4.01:

http://www.w3.org/TR/html401/struct/objects.html#h-13.2
alt %Text; #REQUIRED -- short description --

HTML4.0:
http://www.w3.org/TR/html4/struct/objects.html#h-13.2
alt %Text; #REQUIRED -- short description --
Both say it *is* required.
--
Randy
Jul 20 '05 #8
"Bart Van der Donck" <ba**@nijlen.com> wrote in message
news:b5*************************@posting.google.co m...
<snip>
<button type="submit"> would work too, yes. It are just 2 ways to
achieve the same goal. Is that why Bob shouldn't use my code ?
A scripted HTML page requires support for HTML and JavaScript on the
browser. An HTML submit button (of any sort) only requires support for
HTML. If exactly the same effect can be achieved reliably with pure HTML
it is insane to use JavaScript when the browser pretty much has to have
HTML but may not have JavaScript either available or enabled. If it
exists, the reliable method is the best.
However, by just taking the onClick event away, the form doesn't
submit (just quick test on IE6 here) as you say.
<quote frome="W3C HTML 4.01 Specification"
cite="http://www.w3.org/TR/html4/interact/forms.html#h-17.5">
....
<!ATTLIST BUTTON
%attrs; -- %coreattrs, %i18n, %events --
name CDATA #IMPLIED
value CDATA #IMPLIED -- sent to server when
submitted --
type (button|submit|reset) submit -- for use as form button --
....
type = submit|button|reset [CI]
This attribute declares the type of the button. Possible values:
submit: Creates a submit button. This is the default value.
reset: Creates a reset button.
button: Creates a push button.
....
</quote>

If the HTML spec says it should then IE (or your code) is at fault.

<snip>
... (and is required on IMG elements in HTML 4 anyway)).


Is ALT required on IMG elements in HTML4 ? No it is not.


Yes it is!
About speech/text browsers: yes of course in those cases it is
relevant, or relevant as info for surfers, or when download fails or
...etc

I never met a textbrowser in my logs however. Not sure
about speech browsers, but, fairly, I would be surprised.


Logs do not represent an accurate source of information about web
browsers, only about the user agent strings that those browsers choose
to broadcast (and these days that is often a matter of choice).

Which cave first, the site that is inaccessible to text browsers or the
fact that no text browsers visit it?

Richard.
Jul 20 '05 #9
Theoretically, you are right.
Pactically, interpretations of some W3C specs are possible. And that
is how it should be.

E.g. HTML4+:

W3C specification:
default type <button> is "submit"
Reality:
IE6 doesn't set <button> as "submit" by default
Conclusion:
Don't use that code

W3C specification:
ALT is required for IMG
Reality:
ALT is not required, but recommended
Conclusion:
You don't need to write ALTs for every IMG
Logs do not represent an accurate source of information about web
browsers, only about the user agent strings that those browsers choose
to broadcast (and these days that is often a matter of choice).


The accuracy is reasonable.

Bart
Jul 20 '05 #10
On 8 Sep 2003 02:30:20 -0700, ba**@nijlen.com (Bart Van der Donck)
wrote:
IE6 doesn't set <button> as "submit" by default
Conclusion:
Don't use that code
Relying on defaults is never wise, adding type="submit" hardly costs
anything.
ALT is not required, but recommended
Conclusion:
You don't need to write ALTs for every IMG


The situation is far from the same, your first one is a bug in a
browser if it's not handled properly, missing ALT is an invalid
document, which is quite different.
Logs do not represent an accurate source of information about web
browsers, only about the user agent strings that those browsers choose
to broadcast (and these days that is often a matter of choice).


The accuracy is reasonable.


Please define reasonable, and put some accurate metrics on it, for a
particular site.

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

Jul 20 '05 #11
ji*@jibbering.com (Jim Ley) wrote in message news:<3f***************@news.zen.co.uk>...
On 8 Sep 2003 02:30:20 -0700, ba**@nijlen.com (Bart Van der Donck)
wrote:
IE6 doesn't set <button> as "submit" by default
Conclusion:
Don't use that code
Relying on defaults is never wise, adding type="submit" hardly costs
anything.


Agreed

ALT is not required, but recommended
Conclusion:
You don't need to write ALTs for every IMG


The situation is far from the same, your first one is a bug in a
browser if it's not handled properly, missing ALT is an invalid
document, which is quite different.


Agreed... Both examples were only to demonstrate that W3C
specifications of HTML4 are sometimes not enough as base for webpage
coding. Instead I use something like
(1) define which browsers I want to write for
(2) within (1) check as much browsers as possible (or available)
before putting the code into use

Logs do not represent an accurate source of information about web
browsers, only about the user agent strings that those browsers choose
to broadcast (and these days that is often a matter of choice).


The accuracy is reasonable.


Please define reasonable, and put some accurate metrics on it, for a
particular site.


Reasonable = system administrators have a more or less correct view on
what browsers visit the webserver. It must be possible to broadcast a
different user-agent as Richard says. However that should be a
miniscul minority of the surfing crowd.

Bart
Jul 20 '05 #12
On 8 Sep 2003 08:46:14 -0700, ba**@nijlen.com (Bart Van der Donck)
wrote:
Both examples were only to demonstrate that W3C
specifications of HTML4 are sometimes not enough as base for webpage
coding.
Marking up invalid sites is unquestionably pointless, believing valid
sites are all you should do is also pointless, but valid mark-up
doesn't prevent anything, and will catch an awful lot of errors.
Instead I use something like
(1) define which browsers I want to write for
What on incredibly odd way to develop, why not author for the web?
(2) within (1) check as much browsers as possible (or available)
before putting the code into use


So you only do any QA with the old browsers, sounds an odd way of
doing QA - I bet you charge more for your "maintenance" yeah?
Please define reasonable, and put some accurate metrics on it, for a
particular site.


Reasonable = system administrators have a more or less correct view on
what browsers visit the webserver. It must be possible to broadcast a
different user-agent as Richard says. However that should be a
miniscul minority of the surfing crowd.


No, it's the majority, in fact you probably won't find a UA which
tells the truth... Of course they might do somewhere in the string
aswell as the lies, but then you're relying on the strength of your
measuring script, I've yet to see a good one. Also of course people
reaching your webserver has little to do with people viewing your
site, and then there's the self-fulfilling aspect of logs. Could you
explain why you believe the logs are "more and less accurate" ?

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

Jul 20 '05 #13
"Bart Van der Donck" <ba**@nijlen.com> wrote in message
news:b5**************************@posting.google.c om...
Theoretically, you are right.
Pactically, interpretations of some W3C specs are possible.
And that is how it should be.
A specification that is open to interpretation is a bad specification.
But is the phrase "This is the default value" really that unspecific? Or
the word "REQUIRED" in the DTD next to the ALT attribute on IMG?
E.g. HTML4+:

W3C specification:
default type <button> is "submit"
Reality:
IE6 doesn't set <button> as "submit" by default
Conclusion:
Don't use that code
Yes, <input type="image"> is better supported.
W3C specification:
ALT is required for IMG
Reality:
ALT is not required, but recommended
Hence the use of the word "Required" in the DTD.
Conclusion:
You don't need to write ALTs for every IMG


To Author valid HTML 4 every image does need to have an ALT attribute.
Logs do not represent an accurate source of information about
web browsers, only about the user agent strings that those
browsers choose to broadcast (and these days that is often a
matter of choice).


The accuracy is reasonable.


Logs will accurately report the user agent strings broadcast by
client-side software. User agent strings are _not_ an accurate indicator
of the nature of he client-side software.

Richard.
Jul 20 '05 #14
ji*@jibbering.com (Jim Ley) wrote in message news:<3f***************@news.cis.dfn.de>...
On 8 Sep 2003 08:46:14 -0700, ba**@nijlen.com (Bart Van der Donck)
wrote:
Both examples were only to demonstrate that W3C
specifications of HTML4 are sometimes not enough as base for webpage
coding.
Marking up invalid sites is unquestionably pointless, believing valid
sites are all you should do is also pointless, but valid mark-up
doesn't prevent anything, and will catch an awful lot of errors.
Instead I use something like
(1) define which browsers I want to write for


What on incredibly odd way to develop, why not author for the web?
(2) within (1) check as much browsers as possible (or available)
before putting the code into use


So you only do any QA with the old browsers, sounds an odd way of
doing QA - I bet you charge more for your "maintenance" yeah?


Authoring for the web is a nice idea, but... where are the limits?
Going back to 3+ browsers? Being accessible for LYNX ? It could give a
nice feeling that your site is LYNX-compatible, but is it really
useful? I doubt

I am mostly active in field of web applications and I usually require
IE5+. This gives me enough space to use some client script, xml, css2,
tabular controls and so. Other browsers get an error message "You need
IE5+ to continue". Most of my work consists out of customer login,
intranets etc. and until now I never had someone complaining like "but
I use Netscape 2!!" or so :-) People with that kind of old browsers
mostly have other browsers as well; they know what they are browsing
with and know what to expect.

I believe it's not odd to develop that way. It is a matter of what is
required for what type of thing you want to do. LOT of databases with
browser interfaces set requirements. Especially when it comes to
intra/extranet usage. There is no other choice if you want to use more
complex client scripting.

Of course when developing an "average" website for the public, the
idea must be totally different and it must be compatible for more
browsers. Basically that is a matter of choice of the webmaster - one
says "IE4+ NS4+" other says "HTML3+" other says "800*600+" etc. For
public websites I use something like IE4+ NS4+ 640*480. Now we're not
gonna discuss whether or not that should be HTML3+ or so, OK ;-)
Please define reasonable, and put some accurate metrics on it, for a
particular site.


Reasonable = system administrators have a more or less correct view on
what browsers visit the webserver. It must be possible to broadcast a
different user-agent as Richard says. However that should be a
miniscul minority of the surfing crowd.


No, it's the majority, in fact you probably won't find a UA which
tells the truth... Of course they might do somewhere in the string
aswell as the lies, but then you're relying on the strength of your
measuring script, I've yet to see a good one. Also of course people
reaching your webserver has little to do with people viewing your
site, and then there's the self-fulfilling aspect of logs. Could you
explain why you believe the logs are "more and less accurate" ?


I scan logs with ANALOG which is a well known analyser that interprets
Apache logs. I believe Apache logs are more or less accurate because I
believe that for 5 years or so. Considering the general main stream
information about Apache logs, I do not see many reasons to doubt.

Now I need to go back to work guys!

was a nice discussion, thanks
Bart
Jul 20 '05 #15
On 9 Sep 2003 01:57:21 -0700, ba**@nijlen.com (Bart Van der Donck)
wrote:
Of course when developing an "average" website for the public, the
idea must be totally different and it must be compatible for more
browsers. Basically that is a matter of choice of the webmaster - one
says "IE4+ NS4+" other says "HTML3+" other says "800*600+" etc
No, most people don't say any such thing (and as my Series 60 browsers
are more powerful and contain more javasript possibilities than NN4 it
would seem particularly odd to do anything with those. The
targetting browsers is a very old and discredited way of developing
entirely. For intranets this is just as true, you may still use
certain browser features for fast/cheap development, but that should
not stop you doing everything, intranet platforms change, there's a
number of big companies who've changed browsers, or O/S or similar,
and MS require upgrading of their browsers along side O/S - which they
stop maintaining regularly. Authoring on the intranet suffers all
the same problems as on the web, but has a lot higher cost, when the
MS security upgrade is rolled out corporate wide, and all of a sudden
the holiday booking intranet stops working.
I scan logs with ANALOG which is a well known analyser that interprets
Apache logs. I believe Apache logs are more or less accurate because I
believe that for 5 years or so.


What? You never came across:
http://www.goldmark.org/netrants/webstats/
8 years ago, or
http://www.analog.cx/docs/webworks.html

If Analog doesn't claim the accuracy you're claiming, what do you know
about their excellent tool that they don't?

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

Jul 20 '05 #16

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

Similar topics

1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
2
by: Karuna | last post by:
Hi am quite new to Javascript and CGI related stuff. I have following javascript code : ----------------------------------------------- <html> <head>
2
by: Greg T | last post by:
Hi, I have a rather long form that I don't want people submitting unless they are absolutely sure they are ready. I figured the easiest way to prevent an accidental form submission by way of...
5
by: Don | last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is there some way, using JavaScript, to setup a <form> tag to do this? Thanks, Don ----==...
1
by: Richard Dixson | last post by:
I have code that calls document.myFormName.submit() to submit a form automatically via JavaScript. This works just fine. However, if there is a button (or other form field element) on the form...
4
by: Rick | last post by:
Hello, I'm having trouble with submitting my form when checking to see if data is present in the user-inputted fields. What I want to happen is for the user to input various pieces of data,...
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
18
by: NavinM | last post by:
I have a couple of forms that are misbehaving in FireFox, but work fine in IE. when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the...
4
by: amithoptima3851 | last post by:
<script language="javascript"> function log_Varify() { if(document.frm_index.txt_id.value=="") { alert("Enter your Login Id") frm_index.txt_id.focus() } else...
2
by: vikasbatra | last post by:
i m submitting (posting) a form to some external site url . By clicking on submit it opens up new window (target='_blank' set) and my form is submitted there. but if i tries to submit a form using...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.