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

Javascript onclick not working in IE

I have a select statement with various numbers. Upon clicking on one of the options, you are sent to a page that puts the option value in a session and returns back to the previous page. When it gets back to the page it is supposed to write out a number of <div> tags based on the session variable. I don't know if its asp or IE, but regardless it works in firefox the way I want it to. The code that I'm using is:
Expand|Select|Wrap|Line Numbers
  1. <option onclick="window.location='uploadNum.asp?upNum=1';" <% If Session("uploadNum") = 1 Then Response.Write("selected='selected'") End If %>>1</option>
  2.  
I've tried any number of things to get it to work, such as putting "javascript:" before the "window.location" and making the onclick call a function I made. None of the changes affect how it works in Firefox, but it still fails in IE.

The asp in the code is just so that it starts out selected with the option that is equivalent to the session variable. Since the onclick doesn't work in IE, however, neither does the ASP.

I know its the onclick, because I can manually put in the url and it works fine.

Any advice as to how to fix it would be appreciated. :)
Mar 22 '07 #1
10 6634
scripto
143 100+
I have a select statement with various numbers. Upon clicking on one of the options, you are sent to a page that puts the option value in a session and returns back to the previous page. When it gets back to the page it is supposed to write out a number of <div> tags based on the session variable. I don't know if its asp or IE, but regardless it works in firefox the way I want it to. The code that I'm using is:
Expand|Select|Wrap|Line Numbers
  1. <option onclick="window.location='uploadNum.asp?upNum=1';" <% If Session("uploadNum") = 1 Then Response.Write("selected='selected'") End If %>>1</option>
  2.  
I've tried any number of things to get it to work, such as putting "javascript:" before the "window.location" and making the onclick call a function I made. None of the changes affect how it works in Firefox, but it still fails in IE.

The asp in the code is just so that it starts out selected with the option that is equivalent to the session variable. Since the onclick doesn't work in IE, however, neither does the ASP.

I know its the onclick, because I can manually put in the url and it works fine.

Any advice as to how to fix it would be appreciated. :)

try "window.location.href='uploadNum.asp?upNum=1'; "
Mar 22 '07 #2
mgast
9
You could also try using onchange="" on the select box. You can grab the selected option element with [select box object].selectedElement
Mar 22 '07 #3
try "window.location.href='uploadNum.asp?upNum=1'; "
Tried that already. Still fails to work with IE :(
Mar 23 '07 #4
iam_clint
1,208 Expert 1GB
Example:
Expand|Select|Wrap|Line Numbers
  1. <select onchange="window.location=this.value;">
  2. <option value="#">Select Location</option>
  3. <option value="http://www.google.com">google</option>
  4. <option value="uploadNum.asp?upNum=1">upload</option>
  5. </select> 
Mar 23 '07 #5
It also appears that it wont read anything inside the onclick. I've tried an alert in there as well.

In fact, ive tried onfocus, onchange(in the select tag), and some of the other "on"s, but doesnt seem to read whatever appears in there.

I tested an alert by putting javascript in the header just to make sure it worked and it does. Maybe I have to add something inside script tags in header or include some javascript files? I don't know.
Mar 23 '07 #6
Example:
Expand|Select|Wrap|Line Numbers
  1. <select onchange="window.location=this.value;">
  2. <option value="#">Select Location</option>
  3. <option value="http://www.google.com">google</option>
  4. <option value="uploadNum.asp?upNum=1">upload</option>
  5. </select> 

Good idea, but when it tries to load the page it goes to "blahblahblah/undefined" instead "blahblahblah/uploadNum.asp?upNum=1".

Same with google, says its undefined. That's in firefox. Non-responsive in IE.
Mar 23 '07 #7
iam_clint
1,208 Expert 1GB
works for me in both browsers.
Mar 23 '07 #8
touche

Just made a test.html and test.asp with just that in it.
Works in both browsers.
Guess I'll have to find out what is wrong with my code.

Thanks for the help :)
Mar 23 '07 #9
mgast
9
Example:
Expand|Select|Wrap|Line Numbers
  1. <select onchange="window.location=this.options[this.selectedIndex];">
  2. <option value="#">Select Location</option>
  3. <option value="http://www.google.com">google</option>
  4. <option value="uploadNum.asp?upNum=1">upload</option>
  5. </select> 
Try the code above
Mar 25 '07 #10
iam_clint
1,208 Expert 1GB
you don't have todo selected index when your using a select box. you can just do this.value
Mar 25 '07 #11

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

Similar topics

0
by: malcolm | last post by:
How do I get a web-browser loaded with on-the-fly content and a JavaScript onclick popup function to work? I've embedded an axWebBrowser in my (vb.net) application. The browser starts with...
2
by: bbcrock | last post by:
I created a "cancel" button for my form at the clients' request, I accidentally copied a submit button and added an OnClick event- a very simple javascript.history function. It did not appear to...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
12
by: tshad | last post by:
I have the following code that attaches a Javascript confirm box to my checkbox. When I select the checkbox, the window comes up fine, but it never executes the XfertoDefault_Click function when I...
4
by: devanoy | last post by:
I have a piece of c# code in the Page_Load function. submitButton.Attributes.Add("onClick", "return checkForm('" + this + "','" + SomeTextBox.Text + "')"); When I click the submitButton, it...
0
by: Amil Hanish | last post by:
I have a GridView with a <asp:HyperLinkinside a <TemplateItem>. I want to add the javascript onclick code to confirm the link click. What is the best way to do this? I can put the onclick=......
1
by: grantmx | last post by:
Hey guys - We am having problems with the following code in our form: <tr><td></td><td align=right><input type="image" name="_ctl25:btnSaveLarge" onclick="if (typeof(Page_ClientValidate) ==...
6
by: redridinghood | last post by:
Cant understand why my javascript is working in ie6 but not in mozilla. The javascript that i hav written for validationg my form is below - <script language="JavaScript"...
3
by: safiratec | last post by:
Hi, I want to show a div depending of the value of a <select> option, using 2 functions hidediv() and showdiv() - it is working fine in firefox, but not in IE (tested with IE 6 and 7). <body...
3
by: Mohamed abdul | last post by:
am working with that code, when i click addrow button onclick function is not working in IE but working in mozilla, chrome code is <td><INPUT type="button" value="Add Row"...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.