Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JavaScript not working in IE and Safari, works in Firefox fine.

Reply
Thread Tools

JavaScript not working in IE and Safari, works in Firefox fine.

 
 
dpodkuik@gmail.com
Guest
Posts: n/a
 
      02-17-2006
I have a simple function that does submit for me:

<script language="javascript" type="text/javascript">
function sort()
{
//selected item value from the drop down list

var dud=window.document.statusForm.sortByStaff.value;
window.document.statusForm.action="status.cfm?sort By="+dud;
window.document.statusForm.method="post";
window.document.statusForm.submit();
}
</script>

I have several drop down boxes (<select> element) in which i set
onclick="sort()". Works perfectly in Firefox, and doesn't work in IE
and Safari. Also this same function works fine in all 3 if appended to
a button instead of select element. What am I doing wrong?

 
Reply With Quote
 
 
 
 
dpodkuik@gmail.com
Guest
Posts: n/a
 
      02-17-2006
I have simplified the function based on your advice, but still was only
able to obtain result in Firefox with onclick set instead of onchange.
When I use onchage nothing works anywhere.

function sortStaff(action)
{
window.document.statusForm.action="status.cfm?sort By="+action;
window.document.statusForm.submit();

}

<select name="staff"
onchange="sortStaff(this.options[this.selectedIndex].value)">

I am not switching from POST to GET so I just moved method into form
declaration from javascript.

 
Reply With Quote
 
 
 
 
dpodkuik@gmail.com
Guest
Posts: n/a
 
      02-17-2006
He he

Ok, i found all the dumb things I did. onchange doesn't work when
attached to options . Moved to element declaration and everything
works fine.
IE doesn't support onclick and i guess safari doesn't either.

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      02-17-2006
wrote:

> Ok, i found all the dumb things I did. onchange doesn't work when
> attached to options . Moved to element declaration and everything
> works fine.


JFYI: /That/ is _not_ called an (element) declaration:

<select name="staff" onchange="...">

It is called the start tag of the `select' element.

This is called an element declaration:

<!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->

It declares the `select' element (in the Document Type Definition)
so that you can use it in your markup later.


PointedEars
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      02-18-2006
Thomas 'PointedEars' Lahn said the following on 2/17/2006 3:56 PM:
> wrote:
>
>> Ok, i found all the dumb things I did. onchange doesn't work when
>> attached to options . Moved to element declaration and everything
>> works fine.

>
> JFYI: /That/ is _not_ called an (element) declaration:
>
> <select name="staff" onchange="...">
>
> It is called the start tag of the `select' element.
>
> This is called an element declaration:
>
> <!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->
>
> It declares the `select' element (in the Document Type Definition)
> so that you can use it in your markup later.


To the OP: Ignore Thomas. He thinks he knows more than anybody else but
he seldom does.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: Javascript not working in Firefox "event not defined" Wiseman Javascript 1 07-25-2008 03:04 PM
My movement of banner is not working in IE6, works in IE7 and Firefox, and Safari Terry Javascript 1 10-20-2007 09:38 PM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
Javascript function works in IE, not in Firefox gizoto316 Javascript 2 10-28-2005 09:06 PM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments