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

Works in Firefox, not in IE

I have an extremely simple script that works fine in Firefox and Opera, but does not work in IE or Safari. The script looks like this.

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2.   function autofill(units,uprice) {
  3.     invitems.Units.value=units;
  4.     invitems.UnitPrice.value=uprice;
  5.   }
  6. </script>
  7.  
My form looks like this.

[HTML]<form name="invitems">
<table>
<tr>
<td>
<select name="CategoryID" size="1">
<option onClick="autofill('','')">&nbsp;</option>
<option onClick="autofill('months','20.00')">Service1</option>
<option onClick="autofill('hours','75.00')">Service 2</option>
<option onClick="autofill('hours','50.00')">Service 3</option>
</select>
</td>
<td><input type="text" name="Units" size="5" maxlength="10"></td>
<td><input type="text" name="UnitPrice" size="5" maxlength="10"></td>
</tr>
</table>
</form>
[/HTML]
Can anyone tell me what I need to do to get this to work in IE/Safari?
Mar 29 '08 #1
4 1019
I have an extremely simple script that works fine in Firefox and Opera, but does not work in IE or Safari. The script looks like this.

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2.   function autofill(units,uprice) {
  3.     invitems.Units.value=units;
  4.     invitems.UnitPrice.value=uprice;
  5.   }
  6. </script>
  7.  
My form looks like this.

[HTML]<form name="invitems">
<table>
<tr>
<td>
<select name="CategoryID" size="1">
<option onClick="autofill('','')">&nbsp;</option>
<option onClick="autofill('months','20.00')">Service1</option>
<option onClick="autofill('hours','75.00')">Service 2</option>
<option onClick="autofill('hours','50.00')">Service 3</option>
</select>
</td>
<td><input type="text" name="Units" size="5" maxlength="10"></td>
<td><input type="text" name="UnitPrice" size="5" maxlength="10"></td>
</tr>
</table>
</form>[/HTML]

Can anyone tell me what I need to do to get this to work in IE/Safari?
Mar 29 '08 #2
mrhoo
428 256MB
I'm not sure about Safari, but IE doesn't let you treat options as elements at all.
It's almost like they are properties of the select.

You'll need to write an onchange handler for the select element, and branch your code according to its selectedIndex
Mar 29 '08 #3
Well that pretty much bites the big one. The code I submitted was simple to show only the part that was broken, but for the actual implementation, it is pretty important that each <option> have its own data associated with it because those <option> tags are dynamically generated from a database query. I suppose I could have the javascript function dynamically written instead of the <option> tags, but that makes for more work, more possible complications, and double the queries to the database. *sigh* This is not the first time I've seen IE force me to be inefficient, and I suppose it won't be the last time either.
Mar 29 '08 #4
mrhoo
428 256MB
Yeah, well let me know when people start paying for sites that don't work in IE and Safari. It would be swell if everyone used firefox, but they don't and they won't...
Mar 29 '08 #5

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
5
by: Derek Erb | last post by:
I am banging my head against the wall with this one. The following code snippets work perfectly fine in MSIE6. But produce an error in Firefox and do not work at all. BROWSER.HTM <HTML> .......
11
by: lkrubner | last post by:
We are working on a website that is here: http://www.lauradenyes.com/ The site was working till I put up an .htaccess file that was suppose to redirect all html files to the PHP parser. The...
14
by: David Blickstein | last post by:
I have some XML documents that I want to open in a web browser and be automatically translated to HTML via XSLT. I'm using an xml-stylesheet processing command in a file called "girml.xml". ...
3
by: KBuser | last post by:
I recently developed an internal website with various queries against our SQL server. I added buttons with Response.Redirect. These buttons do not work with Internet Explorer, however when using...
4
by: puja | last post by:
hi all, I have an asp.net website where am including .css file dynamically on page load event. For diff users, there is diff CSS file. So after user logs in, I am setting CSS href on page load....
28
by: entfred | last post by:
I have the following line of html: &nbsp;&nbsp1234&nbsp;&nbsp;&nbsp;&nbsp;&nbspabc&nbsp;&nbsp;&nbspyow In Internet Explorer 6.0, the columns look ok using the above html: 1234 abcd ...
3
by: Arodicus | last post by:
I have a static class method, MyObject.MySub.MyMethod(), which points to a handler in a Flash SWF (but I think that's inconsequential). In reality, the path is a lot longer, so I'd like to make a...
13
by: Stever1975 | last post by:
I'm working on something similiar to a shopping cart item page. There is a table of items. Each item has an image, a textbox for the qty and an image for the add button. When the add image is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.