Question : .innerHTML , <a href> and IE

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.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
<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>

Answer : .innerHTML , <a href> and IE

What about something like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Sub Main()
    Dim file1 As New Dictionary(Of String, String)

    ' Load dictionary with ID (key) and data (value)
    Using reader As New System.IO.StreamReader("test1.txt")
        While Not reader.EndOfStream
            Dim str As String = reader.ReadLine()
            Dim temp() As String = str.Split(",")

            file1.Add(temp(0), str)
        End While
    End Using

    ' Update each key in dictionary with data from second file
    Using reader As New System.IO.StreamReader("test2.txt")
        While Not reader.EndOfStream
            Dim str As String = reader.ReadLine()
            Dim temp() As String = str.Split(",")

            file1(temp(0)) = String.Concat(file1(temp(0)), ",", temp(1))
        End While
    End Using

    ' Write out dictionary to new file
    Using writer As New System.IO.StreamWriter("result.txt")
        For Each item As KeyValuePair(Of String, String) In file1
            writer.WriteLine(item.Value)
        Next
    End Using

End Sub
Random Solutions  
 
programming4us programming4us