submitting a form with javascript & image buttons

B

browntown

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?
 
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.wanadoo.fr/truc/key_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();">
 
R

Ruso

ASM said:
browntown a écrit :

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.wanadoo.fr/truc/key_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


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();">

Dont give < ... name="submit".... > to the submit button.
 
B

browntown

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.
 
B

browntown

<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?
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.

browntown a écrit :

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.wanadoo.fr/truc/key_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


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();">
 
R

Ruso

browntown said:
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.

browntown a écrit :

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.wanadoo.fr/truc/key_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


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();">

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

browntown

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>

browntown said:
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.

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.wanadoo.fr/truc/key_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();">

Can you post your html code as well, or atleast the form part??
 
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();" />
 
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 ! :-(
 
R

Ruso

browntown said:
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>

browntown said:
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.wanadoo.fr/truc/key_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();">

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.
 
B

browntown

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.
 
B

browntown

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.

browntown said:
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>

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.wanadoo.fr/truc/key_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.
 
R

Ruso

browntown said:
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.

browntown said:
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.wanadoo.fr/truc/key_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.
 
B

browntown

Good idea Ruso...I'm going to give this a go. Hopefully this will be as
painless as it sounds.
Ruso said:
browntown said:
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.

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.wanadoo.fr/truc/key_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.
 
B

browntown

yep...just tested it...works perfectly.

Thanks again.

Good idea Ruso...I'm going to give this a go. Hopefully this will be as
painless as it sounds.
Ruso said:
browntown said:
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.wanadoo.fr/truc/key_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.
 
R

Ruso

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

Thanks again.

Good idea Ruso...I'm going to give this a go. Hopefully this will be as
painless as it sounds.
Ruso said:
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.wanadoo.fr/truc/key_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! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top