473,801 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hitting enter causes a page reload (I think)

Hello, I have an input box and a button and when the user clicks the
button, the contents of the input box are placed on the page in list
form. But, when the enter key is used it's as if the page is reloaded
because the page is returned to its initial form with the list gone.
I also have some hidden fields that I make visible, which are also
returned to their hidden state. I'm hoping somebody can help me.

<HTML>
<HEAD> <TITLE>---</TITLE>

<script type="text/javascript">
function AddNewItem()
{
var html = aList.innerHTML ;
aList.innerHTML = html + "<BR>" +
"<INPUT TYPE=checkbox CHECKED NAME=cb1 >" +
frmCreateList.t ext0.value ;
if (submitList.btn SubmitGifts.sty le.visibility=" hidden")
{
aListHeader.sty le.visibility=" visible";
submitList.btnS ubmitGifts.styl e.visibility="v isible";
}
frmCreateList.t ext0.value = "";
frmCreateList.t ext0.focus();
}
</script>
</HEAD>
<BODY id="docBody">
<div style="BORDER-RIGHT: red 3px solid; PADDING-RIGHT:
10px; BORDER-TOP: red 3px solid; PADDING-LEFT: 10px;
Z-INDEX: -100; PADDING-BOTTOM: 10px; BORDER-LEFT: red
3px solid; WIDTH: 100%;
PADDING-TOP: 10px; BORDER-BOTTOM: red 3px solid;
HEIGHT: 95%">

<P align=center><F ONT face=Arial size=7>Please begin adding your
list...</FONT></P>
<P align=center><F ONT face=Arial size=7></FONT>&nbsp;</P>
<P align=center><F ONT face=Arial size=7></FONT>&nbsp;</P>
<P align=center>&n bsp;</P>

<center>
<form name="frmCreate List" action="CreateL ist.asp"
method="post">

<P>&nbsp;<INP UT id=text0 style="WIDTH: 300px" name=text0
width="300" maxlength=50>
<INPUT type="button" value="Add To List"
onclick="AddNew Item()">
</P>
</form>
</center>
<CENTER>&nbsp ;</CENTER>
<CENTER>&nbsp ;</CENTER>
<CENTER>
<DIV style="BORDER-RIGHT: green 3px solid; PADDING-RIGHT:
10px;
BORDER-TOP: green 3px solid;
PADDING-LEFT: 10px; Z-INDEX: -100;
PADDING-BOTTOM: 10px; BORDER-LEFT: green
3px solid; WIDTH: 40%;
PADDING-TOP: 10px; BORDER-BOTTOM: green
3px solid; HEIGHT: 30%">

<div align=top id=aListHeader style="VISIBILI TY: hidden"

<h2>Uncheck any item you do not want to submit.</h2>
</div>
<div id=aList>

</div>
<form id=submitList>
<INPUT type="button" name=btnSubmitG ifts value="Submit
List to Database"
OnClick="Submit Gifts"
style="VISIBILI TY: hidden">
</form>
</DIV>
</CENTER>
</div>
</BODY>
</HTML>

Jul 20 '05 #1
2 6965
On Fri, 26 Sep 2003 18:51:27 GMT, Chris <c9****@yahoo.c om> wrote:
Hello, I have an input box and a button and when the user clicks the
button, the contents of the input box are placed on the page in list
form. But, when the enter key is used it's as if the page is reloaded
because the page is returned to its initial form with the list gone.
I also have some hidden fields that I make visible, which are also
returned to their hidden state. I'm hoping somebody can help me.

<HTML>
<HEAD> <TITLE>---</TITLE>

<script type="text/javascript">
function AddNewItem()
{
var html = aList.innerHTML ;
aList.innerHTML = html + "<BR>" +
"<INPUT TYPE=checkbox CHECKED NAME=cb1 >" +
frmCreateList. text0.value ;
if (submitList.btn SubmitGifts.sty le.visibility=" hidden")
{
aListHeader.sty le.visibility=" visible";
submitList.btnS ubmitGifts.styl e.visibility="v isible";
}
frmCreateList.t ext0.value = "";
frmCreateList.t ext0.focus();
}
</script>
</HEAD>
<BODY id="docBody">
<div style="BORDER-RIGHT: red 3px solid; PADDING-RIGHT:
10px; BORDER-TOP: red 3px solid; PADDING-LEFT: 10px;
Z-INDEX: -100; PADDING-BOTTOM: 10px; BORDER-LEFT: red
3px solid; WIDTH: 100%;
PADDING-TOP: 10px; BORDER-BOTTOM: red 3px solid;
HEIGHT: 95%">

<P align=center><F ONT face=Arial size=7>Please begin adding your
list...</FONT></P>
<P align=center><F ONT face=Arial size=7></FONT>&nbsp;</P>
<P align=center><F ONT face=Arial size=7></FONT>&nbsp;</P>
<P align=center>&n bsp;</P>

<center>
<form name="frmCreate List" action="CreateL ist.asp"
method="post ">

<P>&nbsp;<INP UT id=text0 style="WIDTH: 300px" name=text0
width="300" maxlength=50>
<INPUT type="button" value="Add To List"
onclick="AddNe wItem()">
</P>
</form>
</center>
<CENTER>&nbsp ;</CENTER>
<CENTER>&nbsp ;</CENTER>
<CENTER>
<DIV style="BORDER-RIGHT: green 3px solid; PADDING-RIGHT:
10px;
BORDER-TOP: green 3px solid;
PADDING-LEFT: 10px; Z-INDEX: -100;
PADDING-BOTTOM: 10px; BORDER-LEFT: green
3px solid; WIDTH: 40%;
PADDING-TOP: 10px; BORDER-BOTTOM: green
3px solid; HEIGHT: 30%">

<div align=top id=aListHeader style="VISIBILI TY: hidden"

<h2>Uncheck any item you do not want to submit.</h2>
</div>
<div id=aList>

</div>
<form id=submitList>
<INPUT type="button" name=btnSubmitG ifts value="Submit
List to Database"
OnClick="Submit Gifts"
style="VISIBIL ITY: hidden">
</form>
</DIV>
</CENTER>
</div>
</BODY>
</HTML>


I didn't realize that the enter key creates an onsubmit action for the
form. I have add an onsubmit() -- ONSUBMIT="if (this.submitted )
return true; else return false;" -- to the form. This works in that
it does not reload my page, but now I need to find out how to make the
enter key actually do what the OnClick -- AddNewItem() -- method is
doing for the Button.

Thank you,

Jul 20 '05 #2
On Fri, 26 Sep 2003 19:38:54 GMT, Chris <c9****@yahoo.c om> wrote:
On Fri, 26 Sep 2003 18:51:27 GMT, Chris <c9****@yahoo.c om> wrote:
Hello, I have an input box and a button and when the user clicks the
button, the contents of the input box are placed on the page in list
form. But, when the enter key is used it's as if the page is reloaded
because the page is returned to its initial form with the list gone.
I also have some hidden fields that I make visible, which are also
returned to their hidden state. I'm hoping somebody can help me.

<HTML>
<HEAD> <TITLE>---</TITLE>

<script type="text/javascript">
function AddNewItem()
{
var html = aList.innerHTML ;
aList.innerHTML = html + "<BR>" +
"<INPUT TYPE=checkbox CHECKED NAME=cb1 >" +
frmCreateList .text0.value ;
if (submitList.btn SubmitGifts.sty le.visibility=" hidden")
{
aListHeader.sty le.visibility=" visible";
submitList.btnS ubmitGifts.styl e.visibility="v isible";
}
frmCreateList.t ext0.value = "";
frmCreateList.t ext0.focus();
}
</script>
</HEAD>
<BODY id="docBody">
<div style="BORDER-RIGHT: red 3px solid; PADDING-RIGHT:
10px; BORDER-TOP: red 3px solid; PADDING-LEFT: 10px;
Z-INDEX: -100; PADDING-BOTTOM: 10px; BORDER-LEFT: red
3px solid; WIDTH: 100%;
PADDING-TOP: 10px; BORDER-BOTTOM: red 3px solid;
HEIGHT: 95%">

<P align=center><F ONT face=Arial size=7>Please begin adding your
list...</FONT></P>
<P align=center><F ONT face=Arial size=7></FONT>&nbsp;</P>
<P align=center><F ONT face=Arial size=7></FONT>&nbsp;</P>
<P align=center>&n bsp;</P>

<center>
<form name="frmCreate List" action="CreateL ist.asp"
method="post" >

<P>&nbsp;<INP UT id=text0 style="WIDTH: 300px" name=text0
width="300" maxlength=50>
<INPUT type="button" value="Add To List"
onclick="AddN ewItem()">
</P>
</form>
</center>
<CENTER>&nbsp ;</CENTER>
<CENTER>&nbsp ;</CENTER>
<CENTER>
<DIV style="BORDER-RIGHT: green 3px solid; PADDING-RIGHT:
10px;
BORDER-TOP: green 3px solid;
PADDING-LEFT: 10px; Z-INDEX: -100;
PADDING-BOTTOM: 10px; BORDER-LEFT: green
3px solid; WIDTH: 40%;
PADDING-TOP: 10px; BORDER-BOTTOM: green
3px solid; HEIGHT: 30%">

<div align=top id=aListHeader style="VISIBILI TY: hidden"

<h2>Uncheck any item you do not want to submit.</h2>
</div>
<div id=aList>

</div>
<form id=submitList>
<INPUT type="button" name=btnSubmitG ifts value="Submit
List to Database"
OnClick="Submit Gifts"
style="VISIBI LITY: hidden">
</form>
</DIV>
</CENTER>
</div>
</BODY>
</HTML>


I didn't realize that the enter key creates an onsubmit action for the
form. I have add an onsubmit() -- ONSUBMIT="if (this.submitted )
return true; else return false;" -- to the form. This works in that
it does not reload my page, but now I need to find out how to make the
enter key actually do what the OnClick -- AddNewItem() -- method is
doing for the Button.

Thank you,

Ok, I got everything working. The onsubmit() was changed to --
ONSUBMIT="if (this.submitted ){return true;}
else { AddNewItem(); return false; }"

Thanks for the help!
Jul 20 '05 #3

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

Similar topics

13
2423
by: s_m_b | last post by:
I'm building a suite of online forms for insurance. These have been stripped down from messy MS Word templates, and two of the six, substantially identical, are misbehaving with the .js page that validates some of the content. The correct behaviour is that some fields must have content, some must have valid dates/times. On validation, the form is POSTed to a processing page that flows it into a blank template and emails that elsewhere. ...
8
3394
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if the Java method is called just once and then the page is refreshed. FireFox does not crash at all...
2
3121
by: 23s | last post by:
My site's login page has a form w/ 2 textboxes and a submit button. If I'm in either of those textboxes (i.e., either one of the textboxes has focus), in any given browser, hitting "enter" on my keyboard submits the form. Server side, I handle the click event of the submit button. This is the expected behavior, and this is the behavior irrespective of what browser I use on the login page. However... I have different page that is an...
3
5699
by: michael | last post by:
Good Morning Everyone, I am writing a script to add and remove rows from a table. Here are the two functions: function newRow(rowNo) { var theTable = document.getElementById("table1"); var newRow = theTable.insertRow(rowNo);
5
2083
by: DCC-700 | last post by:
I am using ASP.Net with VB on the 1.1 Framework running on Win XP Pro. I am trying to gauge the time it takes to sort a datagrid using different code sets. But when I am debugging the page there is a long delay before hitting breakpoint in page load. When I initially load the page I hit the breakpoint right away. Then I click on a Sort header in a datagrid, and it takes about 1:45 before the breakpoint (first statement in Page Load) is...
2
1451
by: Brenden Bixler | last post by:
Hello. I've got a long web form that has to reload 6-7 times to validate data (sigh, I know) making for a rocky-enough experience for users. To add insult to injury, each time the page reloads, it loads and scrolls back to the top instead of remaining in the section that caused the page to reload. I'm looking for a way to ensure that when a dropdown box is changed near the bottom of the form (2 screens down from the top) that the page...
2
2164
by: ramanaths | last post by:
Hi I have a page that shows many thumbnail images. on load of this page i have some code that invokes a javascript which shows a message saying 'loading images'... this is hidden once all the page/images loads fully. when i navigate to some other page and then hit the back button of the browser the javascript fires and i get the 'loading images'. the images load fast (maybe from cache). but i was thinking i shouldn't be getting the 'loading...
2
1682
by: Sunfire | last post by:
I was wondering if there was a way to hit enter to insert blank lines while in the designer? I tried this but all it seems to want to do is insert code that really shouldn't be there. For example, I had a heading 1 centered on a page. Right under that I had some words in smaller print right under the heading. When I hit enter after the heading 1, it automatically put the text right below it in a <p></ptag. I don't want this sort of stuff to...
1
3413
by: pendem | last post by:
I mean can set a variable value in a script to be unchanged even after page reload? for example if i set a value of a global variable "val" to 2 ; so using onbeforeunload() or onunload(), i will change the value of variable "val" to 5; so can i in anyway get the value of variable "val" equal to 5? after loading the page..,i mean after onload() event is done/ does my question make any sense? thnx..
0
9556
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10521
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10295
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10271
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10054
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7593
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4263
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2961
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.