Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

.innerHTML , <a href> and IE

Avatar of BenthamLtd
BenthamLtd asked on
JavaScriptHTMLPHP
5 Comments1 Solution532 ViewsLast Modified:
Getting more stumped and hating IE every second to the degree I want to punch their lead developer in the face!

IT WORKS IN FIREFOX.... ARRRGGHHHH!


Basically I have a drop-down menu that changes a <a href> link within a <span>. Users click the drop-down menu option and it populates a <th> with the new value and link. It works flawlessly in FF, but (no surprise here), not IE.

I also know why it's doing it; basically you cannot have open <a>'s when manipulating stuff with .InnerHTML .... in IE anyway.

I've attached the code below and would really appreciate any other options. At the moment I've tried tricking it with a long PHP echo, abusing document.write, changed <span> to <div>....all return "Unknown runtime error" on IE. Slowly running out of ideas!

Or if someone would be kind enough to point in the right direction using AJAX, I'll happily take that as an option!

Many thanks as always.
<html>  <!-- this is just so Experts Exchange can try syntax highlighting -->


<!-- this is the select object with onchange .innerHTML event -->

<select name="searchclassic_col1" id="searchclassic_col1" style="font-size:9px;" onchange="document.getElementById('searchclassic_col1_span').innerHTML='<a href=db.php?cmd=search_classic&sort='+this[this.selectedIndex].value+'>'+this[this.selectedIndex].text+'</a>'; createCookie('searchclassic_col1_value', this[this.selectedIndex].value, 7); createCookie('searchclassic_col1_text', this[this.selectedIndex].text, 7); location.reload(true);">

<option value="" selected="selected">select from list....</option>
            <option value="" disabled="disabled">&nbsp;</option>
			<?php foreach ($searchclassic_columns_array as $name => $db_field) { ?>
        	<option value="<?php echo $db_field; ?>"><?php echo $name; ?></option><?php } ?></select>&nbsp;  <!-- drop-down options acquired from PHP array -->

<!-- turned column names into PHP sessions so it remembers what users selected -->

<?php 
// FUNCTION TO PARSE COLUMN NAME INTO DYNAMIC HYPERLINK. MUST BE DEFINED AFTER DECLARING JAVASCRIPT COOKES TO PHP SESSIONS (SEE ABOVE).
// THIS ALSO PARSES STORED SESSION VARIABLE INTO ROW NAME FOR DISPLAYING RESULTS.
function cookie_crumbler($column,$default_value) {
	if (!$_SESSION[$column] || $_SESSION[$column] == "null") { return $default_value; } else { return $_SESSION[$column]; }	
}

?>


<!-- this is one of the table rows with the <span> -->
 <th><a href="db.php?cmd=search_classic&sort=<?php echo cookie_crumbler("searchclassic_col1_value","Status"); ?><?php if (!$_GET['dir']) { echo "&dir=DESC"; }?>">
        <span id="searchclassic_col1_span"><?php echo cookie_crumbler("searchclassic_col1_text","Status"); ?></span>
		
		<?php if ($_GET['sort'] == cookie_crumbler("searchclassic_col1_value","Status") && $_GET['dir'] == "") { ?><img src="img/inbox/up-arrow.gif" border="none" /><?php } else if ($_GET['sort'] == cookie_crumbler("searchclassic_col1_value","Status") && $dir = "ASC") { ?><img src="img/inbox/down-arrow.gif" border="none" /><?php } else echo ""; ?></a></th>

<!-- notice the <span> in the middle of the <a href> tag. This is what is causing the problem...in IE... -->


</html>
ASKER CERTIFIED SOLUTION
Avatar of Dean OBrien
Dean OBrienFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers