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

D

dpodkuik

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?sortBy="+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?
 
D

dpodkuik

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?sortBy="+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.
 
D

dpodkuik

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.
 
T

Thomas 'PointedEars' Lahn

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
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 2/17/2006 3:56 PM:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top