Hidden button
Moderator: General Moderators
Hidden button
Can we make the button invisible? The reason is when we press 'Enter', the form will automatically submit. And I don't want that submit button visible. Can we do that?
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
correct me if I'm wrong, but doesn't an enterpress submit the form already by default?
when working in say an input="text" and you press enter you submit the current form...
textarea's and selects don't work with that though.
but if you have a form with textfields only you don't need the submit button at all.
other option if you truly do need a submit thingie:
make a 1px image with same colour as your page background and use that as your submit "button".
give us some more detail about what kind of form it will be, you could also tie js's on it, like CoderGoblin said.
when working in say an input="text" and you press enter you submit the current form...
textarea's and selects don't work with that though.
but if you have a form with textfields only you don't need the submit button at all.
other option if you truly do need a submit thingie:
make a 1px image with same colour as your page background and use that as your submit "button".
give us some more detail about what kind of form it will be, you could also tie js's on it, like CoderGoblin said.
For my form, I want to make when I press 'Enter', the form will automatically submit (do some transaction) at another page and return to this page again. Actually if I display the button also can. But for me, if I can hide that button is better. I also not very understand how to use javascript to do this. Can anybody explain more detail? Thanx..
it seems you need a keyboard Listner or such...
I did a small bit of research for ya...it seems you should call something like this on the onkeypress event... I guess you should put the event on all you form items... (I haven't tested this yet...)
I did a small bit of research for ya...it seems you should call something like this on the onkeypress event... I guess you should put the event on all you form items... (I haven't tested this yet...)
Code: Select all
<html><head>
<script language="javascript">
function myListner(e) {
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
// XX should be the code for an enter, I don't know the number for it. google should help you with this
if (code == XX) {
document.formsї0].submit();
}
}
</script>
</head><body>
<form action="target.html" method="post">
<input type="Text" name="blah" size="10" onkeypress="myListner(event)">
</form>
</body>
</html>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
For your information an example of <noscript> tag
Regards
Code: Select all
<form name="dosomthing" action="next.php">
<select name="myname" onchange="javascript:submit();"
<option value="0">. . .</option>
<option value="1">option1</option>
<option value="2">option2</option>
<option value="3">option3</option>
</select>
<noscript><input type="submit" value="Ok"></noscript>
</form>-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
yeah that was my first thought as well...magicrobotmonkey wrote:Yea and you might want to check into where to put the onkeypress() im not sure if it will pick up all keypresses from being in the text field? Maybe in the body tage like onLoad or something?
I think it can be done... You'll need to set up a global keypress listner that checks what key was pressed and then if it's an enter submit the form.
however, you will only be able to submit 1 form.
if you work with onkeypress you could create an extra par stating what form it is using this. then use the submit on the parameter.
I hope this helped.