By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,813 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

submitting a form with javascript & image buttons

P: n/a
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 ass and the
app will be used internally so I'm not too worried about users who
aren't using javascript. I'm using the following javascript to detect
whether or not they've hit enter:
if(document.layers)
{
document.addEventLister('onkeypress', kpress, true);
}
document.onkeypress=kpress;

function kpress(e)
{
if(window.event)
{
//ie code
key = window.event.keyCode;
}
else
{
key = e.which;
}

//user has pressed enter/return...let's submit the form
if(key == 13)
{
document.forms[0].submit();
}
}
this works fine. It submit all inputs fine...with the exception of my
image buttons. I'm using "image_x" to validate whether or not the form
was submitted by the user. Since "image" type inputs are not being
submitted I can't validate the form. If I change the "image" to
"submit" I get a "Object doesn't support this property or method" error
in IE and a "document.forms[0].submit is not a function" in firefox.

anyone have any ideas?

Nov 13 '06 #1
Share this Question
Share on Google+
16 Replies


P: n/a
I did a quick search of the group and found this link:

http://www.faqts.com/knowledge_base/.../fid/129/lang/

unfortunately, it sounds like there's no way around this without
rewriting some logic.
browntown wrote:
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 ass and the
app will be used internally so I'm not too worried about users who
aren't using javascript. I'm using the following javascript to detect
whether or not they've hit enter:
if(document.layers)
{
document.addEventLister('onkeypress', kpress, true);
}
document.onkeypress=kpress;

function kpress(e)
{
if(window.event)
{
//ie code
key = window.event.keyCode;
}
else
{
key = e.which;
}

//user has pressed enter/return...let's submit the form
if(key == 13)
{
document.forms[0].submit();
}
}
this works fine. It submit all inputs fine...with the exception of my
image buttons. I'm using "image_x" to validate whether or not the form
was submitted by the user. Since "image" type inputs are not being
submitted I can't validate the form. If I change the "image" to
"submit" I get a "Object doesn't support this property or method" error
in IE and a "document.forms[0].submit is not a function" in firefox.

anyone have any ideas?
Nov 13 '06 #2

P: n/a
ASM
browntown a écrit :
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".
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows
this works fine. It submit all inputs fine...with the exception of my
image buttons.
Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #3

P: n/a

ASM wrote:
browntown a écrit :
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".

Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows
this works fine. It submit all inputs fine...with the exception of my
image buttons.

Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dont give < ... name="submit".... to the submit button.

Nov 13 '06 #4

P: n/a
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
ASM wrote:
browntown a écrit :
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".

Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows
this works fine. It submit all inputs fine...with the exception of my
image buttons.

Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #5

P: n/a
<cite>Dont give < ... name="submit".... to the submit button. </cite>

Ruso...if I remove the name of the image button then that x and y
coordinates will submit...so it seems like I'm almost there...but don't
the x and y coordinates need a value greater than 0 for my php to work?

if($_REQUEST['x'])?

I just tried it and it does not validate the form.

am I missing something?

browntown wrote:
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
ASM wrote:
browntown a écrit :
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".
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows
this works fine. It submit all inputs fine...with the exception of my
image buttons.
Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #6

P: n/a

browntown wrote:
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
ASM wrote:
browntown a écrit :
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".
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows
this works fine. It submit all inputs fine...with the exception of my
image buttons.
Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Can you post your html code as well, or atleast the form part??

Nov 13 '06 #7

P: n/a
My form looks like:

<form name="form1" id="form1" method="get" action="">

<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />

<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>

</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
ASM wrote:
browntown a écrit :
so I have this application I'm nearly finished with. The only thingthe
client has requested is the ability to submit the form by pressing
"enter".
>
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.
>
(*) except NC4 which supports this feature
only if there is not more than one input field.
>
The problem could be to avoid submitting if last field is not reached.
>
A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.
>
Not tested with IE Windows
>
this works fine. It submit all inputs fine...with the exception of my
image buttons.
>
Only ONE submit button would be better.
>
My example works too with an image button
>
<input type="image" src="asm.gif" width="50" />
>
Except with IE :-(
>
Medication :
>
<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>
>
<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
>
>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Can you post your html code as well, or atleast the form part??
Nov 13 '06 #8

P: n/a
ASM
browntown a écrit :
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
<input type="submit" name="submit_x" value="GO" onkeydown="this.click();" />
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #9

P: n/a
ASM
browntown a écrit :
My form looks like:

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>
<input type="image" class="button" src="../images/btn_login.png"
name="submit_x" tabindex="3" />
^^^^^^^^^^^^^^
without a name it can't be sent to the php ! :-(

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #10

P: n/a

browntown wrote:
My form looks like:

<form name="form1" id="form1" method="get" action="">

<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />

<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>

</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.
>
Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.
>
In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
>
>
ASM wrote:
browntown a écrit :
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".

Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows

this works fine. It submit all inputs fine...with the exception of my
image buttons.

Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Can you post your html code as well, or atleast the form part??

Appeareantly when enter is pressed the image coordiantes are not
passed, if you remove your JS script and hit enter you will get the
same result (x=0&y=0). But I dont see any inconvinience to this. The
form is submitted, and you must be able to retrive the results.

P.S. Work with password using get method is not a good idea.
P.P.S. And yes put the name to the button but not "submit", this will
be just nicer code, but it not nesesary using img objet.

Nov 13 '06 #11

P: n/a
now i'm starting to confuse myself...I removed the name of the button
when I was trying something ruso suggested. It does in fact have a name
and works fine.

ASM wrote:
browntown a écrit :
My form looks like:

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>

<input type="image" class="button" src="../images/btn_login.png"
name="submit_x" tabindex="3" />
^^^^^^^^^^^^^^
without a name it can't be sent to the php ! :-(

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #12

P: n/a
yes the form does submit...as do the image coordinates but the issue is
that in my php the fact that x and y don't have a value will prove to
be a problem. Because I'm using an image button i'm expecting a user to
click someone on that button...i'm expecting the button to have a x and
y coordinate....so is PHP. If php doesn't see a value for x or a value
for y it won't know to execute the rest of my code.

Regarding the GET...i use GET to debug sites...to make sure what
variables are and arent' getting passed. This will be changed when I am
ready to go live.

I appreciate your guys help. I'm at the point now where I may have to
create a hidden input field and include that in my php validation.
Ruso wrote:
browntown wrote:
My form looks like:

<form name="form1" id="form1" method="get" action="">

<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />

<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>

</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.


ASM wrote:
browntown a écrit :
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".
>
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.
>
(*) except NC4 which supports this feature
only if there is not more than one input field.
>
The problem could be to avoid submitting if last field is not reached.
>
A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will executetab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.
>
Not tested with IE Windows
>
this works fine. It submit all inputs fine...with the exceptionof my
image buttons.
>
Only ONE submit button would be better.
>
My example works too with an image button
>
<input type="image" src="asm.gif" width="50" />
>
Except with IE :-(
>
Medication :
>
<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>
>
<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
>
>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
>
Can you post your html code as well, or atleast the form part??


Appeareantly when enter is pressed the image coordiantes are not
passed, if you remove your JS script and hit enter you will get the
same result (x=0&y=0). But I dont see any inconvinience to this. The
form is submitted, and you must be able to retrive the results.

P.S. Work with password using get method is not a good idea.
P.P.S. And yes put the name to the button but not "submit", this will
be just nicer code, but it not nesesary using img objet.
Nov 13 '06 #13

P: n/a

browntown wrote:
yes the form does submit...as do the image coordinates but the issue is
that in my php the fact that x and y don't have a value will prove to
be a problem. Because I'm using an image button i'm expecting a user to
click someone on that button...i'm expecting the button to have a x and
y coordinate....so is PHP. If php doesn't see a value for x or a value
for y it won't know to execute the rest of my code.

Regarding the GET...i use GET to debug sites...to make sure what
variables are and arent' getting passed. This will be changed when I am
ready to go live.

I appreciate your guys help. I'm at the point now where I may have to
create a hidden input field and include that in my php validation.
Ruso wrote:
browntown wrote:
My form looks like:
>
<form name="form1" id="form1" method="get" action="">
>
<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />
>
<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />
>
<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>
>
</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.
>
Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.
>
In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
>
>
ASM wrote:
browntown a écrit :
so I have this application I'm nearly finished with. The onlything the
client has requested is the ability to submit the form by pressing
"enter".

Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows

this works fine. It submit all inputs fine...with the exception of my
image buttons.

Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date

Can you post your html code as well, or atleast the form part??

Appeareantly when enter is pressed the image coordiantes are not
passed, if you remove your JS script and hit enter you will get the
same result (x=0&y=0). But I dont see any inconvinience to this. The
form is submitted, and you must be able to retrive the results.

P.S. Work with password using get method is not a good idea.
P.P.S. And yes put the name to the button but not "submit", this will
be just nicer code, but it not nesesary using img objet.
Just one thing: 0 IS a value
when there is no value in get method you see "x=&y=" but "x=0&y=0" has
a value, which means that button was pressed. What you can do in PHP
side is check the length of the x and y values. If length is <1 then
form was not submited otherwize it was.

Nov 13 '06 #14

P: n/a
Good idea Ruso...I'm going to give this a go. Hopefully this will be as
painless as it sounds.
Ruso wrote:
browntown wrote:
yes the form does submit...as do the image coordinates but the issue is
that in my php the fact that x and y don't have a value will prove to
be a problem. Because I'm using an image button i'm expecting a user to
click someone on that button...i'm expecting the button to have a x and
y coordinate....so is PHP. If php doesn't see a value for x or a value
for y it won't know to execute the rest of my code.

Regarding the GET...i use GET to debug sites...to make sure what
variables are and arent' getting passed. This will be changed when I am
ready to go live.

I appreciate your guys help. I'm at the point now where I may have to
create a hidden input field and include that in my php validation.
Ruso wrote:
browntown wrote:
My form looks like:

<form name="form1" id="form1" method="get" action="">

<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />

<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>

</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the formfine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.


ASM wrote:
browntown a écrit :
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".
>
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.
>
(*) except NC4 which supports this feature
only if there is not more than one input field.
>
The problem could be to avoid submitting if last field is notreached.
>
A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.
>
Not tested with IE Windows
>
this works fine. It submit all inputs fine...with the exception of my
image buttons.
>
Only ONE submit button would be better.
>
My example works too with an image button
>
<input type="image" src="asm.gif" width="50" />
>
Except with IE :-(
>
Medication :
>
<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>
>
<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
>
>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
>
Can you post your html code as well, or atleast the form part??
>
>
Appeareantly when enter is pressed the image coordiantes are not
passed, if you remove your JS script and hit enter you will get the
same result (x=0&y=0). But I dont see any inconvinience to this. The
form is submitted, and you must be able to retrive the results.
>
P.S. Work with password using get method is not a good idea.
P.P.S. And yes put the name to the button but not "submit", this will
be just nicer code, but it not nesesary using img objet.

Just one thing: 0 IS a value
when there is no value in get method you see "x=&y=" but "x=0&y=0" has
a value, which means that button was pressed. What you can do in PHP
side is check the length of the x and y values. If length is <1 then
form was not submited otherwize it was.
Nov 13 '06 #15

P: n/a
yep...just tested it...works perfectly.

Thanks again.
browntown wrote:
Good idea Ruso...I'm going to give this a go. Hopefully this will be as
painless as it sounds.
Ruso wrote:
browntown wrote:
yes the form does submit...as do the image coordinates but the issue is
that in my php the fact that x and y don't have a value will prove to
be a problem. Because I'm using an image button i'm expecting a user to
click someone on that button...i'm expecting the button to have a x and
y coordinate....so is PHP. If php doesn't see a value for x or a value
for y it won't know to execute the rest of my code.
>
Regarding the GET...i use GET to debug sites...to make sure what
variables are and arent' getting passed. This will be changed when I am
ready to go live.
>
I appreciate your guys help. I'm at the point now where I may have to
create a hidden input field and include that in my php validation.
>
>
Ruso wrote:
browntown wrote:
My form looks like:
>
<form name="form1" id="form1" method="get" action="">
>
<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />
>
<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />
>
<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>
>
</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.
>
Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to getsent.
>
In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.
>
>
ASM wrote:
browntown a écrit :
so I have this application I'm nearly finished with. The only thing the
client has requested is the ability to submit the form bypressing
"enter".

Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado...enter_tab..htm
fill first field and valid it with touch Enter, that will execute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows

this works fine. It submit all inputs fine...with the exception of my
image buttons.

Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date

Can you post your html code as well, or atleast the form part??


Appeareantly when enter is pressed the image coordiantes are not
passed, if you remove your JS script and hit enter you will get the
same result (x=0&y=0). But I dont see any inconvinience to this.. The
form is submitted, and you must be able to retrive the results.

P.S. Work with password using get method is not a good idea.
P.P.S. And yes put the name to the button but not "submit", this will
be just nicer code, but it not nesesary using img objet.
Just one thing: 0 IS a value
when there is no value in get method you see "x=&y=" but "x=0&y=0" has
a value, which means that button was pressed. What you can do in PHP
side is check the length of the x and y values. If length is <1 then
form was not submited otherwize it was.
Nov 13 '06 #16

P: n/a

browntown wrote:
yep...just tested it...works perfectly.

Thanks again.
browntown wrote:
Good idea Ruso...I'm going to give this a go. Hopefully this will be as
painless as it sounds.
Ruso wrote:
browntown wrote:
yes the form does submit...as do the image coordinates but the issue is
that in my php the fact that x and y don't have a value will prove to
be a problem. Because I'm using an image button i'm expecting a user to
click someone on that button...i'm expecting the button to have a xand
y coordinate....so is PHP. If php doesn't see a value for x or a value
for y it won't know to execute the rest of my code.

Regarding the GET...i use GET to debug sites...to make sure what
variables are and arent' getting passed. This will be changed when I am
ready to go live.

I appreciate your guys help. I'm at the point now where I may have to
create a hidden input field and include that in my php validation.


Ruso wrote:
browntown wrote:
My form looks like:

<form name="form1" id="form1" method="get" action="">

<label for="user" id="lblUsername">Username:</label>
<input type="text" name="user" tabindex="1" id="user" />

<label for="pass" id="lblPass">Password:</label>
<input type="password" name="pass" tabindex="2" id="pass" />

<div class="button"><input type="image" src="../images/btn_login.png"
tabindex="3" /></div>

</form>
Ruso wrote:
browntown wrote:
thanks for the info ASM.

Perhaps I was unclear in my initial post. I can submit the form fine
with the exception that my image button doesn't appear to get sent.

In my php i'm validating whether or not a user has clicked the submit
button by a simple if($_REQUEST['submit_x') statement. Since this
variable never gets sent my php will not validate the form.


ASM wrote:
browntown a écrit :
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".
>
Any browser(*) submit the form by pressing touch 'Enter'.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.
>
(*) except NC4 which supports this feature
only if there is not more than one input field.
>
The problem could be to avoid submitting if last field isnot reached.
>
A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that willexecute tab
and you'll be in next field.
Hit Enter still to reach submit button and continue with Enter.
>
Not tested with IE Windows
>
this works fine. It submit all inputs fine...with the exception of my
image buttons.
>
Only ONE submit button would be better.
>
My example works too with an image button
>
<input type="image" src="asm.gif" width="50" />
>
Except with IE :-(
>
Medication :
>
<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>
>
<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
>
>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
>
Can you post your html code as well, or atleast the form part??
>
>
Appeareantly when enter is pressed the image coordiantes are not
passed, if you remove your JS script and hit enter you will get the
same result (x=0&y=0). But I dont see any inconvinience to this. The
form is submitted, and you must be able to retrive the results.
>
P.S. Work with password using get method is not a good idea.
P.P.S. And yes put the name to the button but not "submit", this will
be just nicer code, but it not nesesary using img objet.
>
Just one thing: 0 IS a value
when there is no value in get method you see "x=&y=" but "x=0&y=0" has
a value, which means that button was pressed. What you can do in PHP
side is check the length of the x and y values. If length is <1 then
form was not submited otherwize it was.
Always welcome! :)

Nov 13 '06 #17

This discussion thread is closed

Replies have been disabled for this discussion.