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

javascript __doPostBack() problem in IE

3
Hello, I have an address form which has a select box with countries and another select box with provinces.

When I select a certain country I cause a postback by using javascript __doPostBack function. I also have a submit button.

It works perfectly in both firefox and IE when I click on selectbox and select a country - it posts back and then on page load I populate the provinces based on the country just selected.

- EXCEPT: when I click on the select in IE, then select a country BUT I don't click on it, I hit enter to select that country.

This causes IE to actually submit the form as if I had clicked the submit button, which is NOT what I want.

Now if i change the type of the button to "button" instead of "submit", it doesn't behave that way, but then the user can't submit by hitting Enter.

I'm sure someone has come across this problem.
Is there a workaround for this?
Any idea on how to fix this?
Apr 26 '07 #1
3 4626
Frinavale
9,735 Expert Mod 8TB
Hello, I have an address form which has a select box with countries and another select box with provinces.

When I select a certain country I cause a postback by using javascript __doPostBack function. I also have a submit button.

It works perfectly in both firefox and IE when I click on selectbox and select a country - it posts back and then on page load I populate the provinces based on the country just selected.

- EXCEPT: when I click on the select in IE, then select a country BUT I don't click on it, I hit enter to select that country.

This causes IE to actually submit the form as if I had clicked the submit button, which is NOT what I want.

Now if i change the type of the button to "button" instead of "submit", it doesn't behave that way, but then the user can't submit by hitting Enter.

I'm sure someone has come across this problem.
Is there a workaround for this?
Any idea on how to fix this?

Hi Rizzy!

You could use a little bit of JavaScript to trap the event when the enter key is pressed

-Frinny
Apr 27 '07 #2
rizzy
3
thanks Frinny,

but it's too late by the time it gets to catchKeyPress(). The postback happens before this. And I forgot mention that this only happens with select boxes that have __doPostBack(eventarget,eventarg) tied to their onchange event. Maybe IE mixes up the eventtarget somehow or something. I don't know how i'm gonna fix this.
Apr 30 '07 #3
Frinavale
9,735 Expert Mod 8TB
thanks Frinny,

but it's too late by the time it gets to catchKeyPress(). The postback happens before this. And I forgot mention that this only happens with select boxes that have __doPostBack(eventarget,eventarg) tied to their onchange event. Maybe IE mixes up the eventtarget somehow or something. I don't know how i'm gonna fix this.
Hi Rizzy,

Maybe try using a button since this solution works. Then simply write some JavaScript function that catches the key up event for ever element on the form and checks which form element this event happened for. Compare this value to the select boxes and if it matches do not the submit since its going to post back anyways. Otherwise submit the form.

I hope this helps you!
Good luck,

-Frinny
May 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Juan Jose Costello Levien | last post by:
Hello, My name is Juan. I am new to the forum. Here I leave you a problem to see if you can help me. General Description I am developing an application in Visual Basic 6.
2
by: john | last post by:
I would like to do some client side stuff whenever my page is posting back. My page has a lot of different buttons and links that will cause a postback. I would rather not have to put something in...
1
by: Adrian | last post by:
I appear to be losing ViewState information when calling the __doPostBack function. I am attempting to use the showModalDialog to load a new web page which confirms that a user wishes to save a...
6
by: Jim | last post by:
Group, How would I go about firing a JavaScript method from a C# method in the aspx code behind file? It seems as though this could not be done since JavaScript is executed from within the Web...
3
by: lanem | last post by:
I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks.
0
by: Steve Richter | last post by:
ok, I admit I dont know what I am doing ... When a user clicks on a <tr> in a <table> I want the page to be posted back to the server with info as to what row was clicked. <tr...
2
by: The Crow | last post by:
i want to raise an event on the server with a javascript call on the client. i found a solution but i think its not so elegant. the solution is: i call __doPostBack("RefreshPage", ""); from...
14
by: Rich | last post by:
I am converting my enterprise solution from VS 2003 (.NET v1.1.4322) to VS 2005 (.NET v2.0.50727). The entire solution uses serveral technologies - Windows Server 2003 (AD, SQL Server 2000, IIS,...
0
by: codeshelp | last post by:
I have a gridview that has a ButtonField(Insert) that calls a detailsview which allows you to insert data to the gridview. The postback for this buttonField is:...
7
by: pardesiya | last post by:
Friends, I need to write a javascript function (which will be called on clicking a button) to return the currently selected item from a drop- down list whose rendered html is below. <select...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...

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.