Stack overflow in IE but nothing in Firefox

G

giankara

First of all, sorry for my English!!!
I want to display or not a text field (named other_category) depending
on the value of text field named exercise_category. If last's value is
"other" then the "other_category" field should be displayed. The
following script is placed in the page.


<script language="javascript">
function onchange(){
var x=document.getElementById("exercise_category");
var y=document.getElementById("other_category");

var value=x.options[x.selectedIndex].value;

if (value=="other"){

y.style.display="";
}
else {
y.style.display="none";
}
}
</script>



The "exercise_category" field is generated dynamically from a
database.The following code is where the field is generated and the
call on Javascript is happening.



<div align="center">
<table width="80%" border="1">
<tr>
<th scope="row"><div align="left">Êáôçãïñßá
Üóêçóçò </div></th>
<th scope="row"><select name="exercise_category"
id="exercise_category" onChange="onchange();"><?php
require_once('bookmark_fns.php');
session_start();
$db_conn = db_connect();
$query = "select distinct exercise_category from exercise";
$result = mysql_query($query, $db_conn);
while ($row=mysql_fetch_array($result)){
$exercise_category=stripslashes($row['exercise_category']);
$display_block.="<option value=\"$exercise_category\">
$exercise_category</option>";
}
$display_block.="<option value=\"other\"> ¶ëëç</option>";
echo $display_block;
?>


</select></th>
</tr>
<tr>
<th scope="row"><div align="left">ÍÝá
êáôçãïñßá Üóêçóçò </div></th>
<th scope="row"><input name="other_category"
type="text" id="other_category" maxlength="30" style="display: none">
</th>
</tr>



There is no problem in Firefox, when i choose other the
"other_category" text field is displayed. But in IE stack overflow is
happening when there is a call on Javascript.

Please help!!!!!!!!!!!!!!!!!!!!!!
Hello from beautiful Greece!!!!!!!!!!!!!
 
M

Martin Honnen

giankara said:
function onchange(){
<th scope="row"><select name="exercise_category"
id="exercise_category" onChange="onchange();">

Change the name of the function to something other than 'onchange' e.g.
simply use
function categoryChangeHandler () { ... }
<select onchange="categoryChangeHander();">

Or explictly call
<select onchange="window.onchange();">

Note, independent of your problem, you can simply pass the this object
to the handler e.g.

<select onchange="categoryChangeHander(this);" ...>


function categoryChangeHandler (select) {
if (select.value == "other")
 

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,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top