473,385 Members | 1,409 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.

onchange not recognized by IE?!?

I have a form that is used for uploading photos. I have a check box for
specifying that the photo being uploaded should appear on a specific
web page rather than just be stored in the database for future posting.
When this check box checked two text boxes should appear in the form
for adding a url. The problem is: internet explorer doesn't seem to be
recognizing the onchange event as I've called it. What am I doing
wrong? Here's the code:

function triggerpages(){
var checks = document.getElementsByTagName('INPUT');
for(var i=0;i<checks.length;i++){
if(/web\-page/.test(checks[i].name)){
checks[i].onchange = function(){showpages();};
}
}
}

function showpages(){
alert("HI");
var pages = document.getElementsByTagName('INPUT');
alert(pages.length);
for(var i=0;i<pages.length;i++){
if(/page[0-9]/.test(pages[i].name)){
if(pages[i].style.display == none){
pages[i].style.display = block;
}else{
pages[i].style.display = none;
}
}
}
}
and the HTML:

<table border="0" cellpadding="10" cellspacing="0" id="upload_form">
<form action="/admin/photos" method="post"
enctype="multipart/form-data">

<tr>
<td>
Image file
</td>
<td>
<input type="file" value="file1" name="file1"
accept="image/jpg,image/gif" />
</td>
</tr>

<tr>
<td valign="top">
Caption
</td>
<td >

<textarea name="caption" cols="60" rows="4"
Photo.</textarea>

</td>
</tr>

<tr>
<td valign="top">

Placement
</td>
<td>

<input type="checkbox" name="web-page" checked />
Displayed in web page?
<br>

<input type="checkbox" name="in-index" checked />
Displayed on story index (small thumbnail)?
<br>

<input type="checkbox" name="in-blurb" />
Display thumbnail in home page story description?
<br>

<input type="checkbox" name="in-news-index" />
Displayed as the headline graphic on the news index?
<br>

<input type="checkbox" name="in-home-rotate" />
Photo rotation on home page?
<br>
</td>
</tr>
<tr class="page_entry">
<td>URL</td>

<td><input type="text" name="page1" value="" /></td>
</tr>
<tr class="page_entry">
<td>URL</td>
<td><input type="text" name="page2" value="" /></td>
</tr>
<tr>
<td align="center" colspan="2">

<input type="submit" value="Upload" name="submit" />
</td>
</tr>

</form>
</table>
<script language="javascript">
<!--
triggerpages();
//-->
</script>

Jul 23 '05 #1
2 9116


otto wrote:

var checks = document.getElementsByTagName('INPUT');
for(var i=0;i<checks.length;i++){
if(/web\-page/.test(checks[i].name)){
checks[i].onchange = function(){showpages();}; <input type="checkbox" name="web-page" checked />
Displayed in web page?


IE's documentation is here
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onchange.asp>
If you want an event handler on a checkbox that is triggered when the
checkbox is checked or unchecked then use onclick.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Thanks for your reply. That does seem to do the trick. I've been trying
to steer clear of onclick for accessibility reasons, but I guess I'll
get around that by using an onkeypress event too.

Thanks again.

Jul 23 '05 #3

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

Similar topics

2
by: Jeff | last post by:
Hi Everyone, I'm having a problem with onChange. The tag looks like: <input:text bean = "" name="X" label="Y" attributesText="onChange=\"clear()\""> </input:text> if i replace, onChange...
2
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time ,...
4
by: Bart van Deenen | last post by:
Hi all I have a script where I dynamically create multiple inputs and selects from a script. The inputs and selects must have an associated onchange handler. I have the script working fine on...
5
by: Good Man | last post by:
Hi there I'm adding form fields on the fly with some javascript DOM programming. I basically just clone a hidden <div>, then adjust node properties to make this new <div> have unique values...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
3
by: b_naick | last post by:
I realize that the onChange event for a drop down can be trapped as follows: <select name="myDropDown" onChange="somefunc"> Is it possible to trap the onChange event outside of the select...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
2
by: pantagruel | last post by:
The following code: FileSystemWatcher watcher = new FileSystemWatcher(); RenderingQ = ConfigurationSettings.AppSettings; watcher.Path = RenderingQ; watcher.NotifyFilter =...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.