Reputation: 85
I've been troubleshooting this for about an hour now with no anwser to my problem. I've ruled out that chrome is not loading my javascript file. It loads it just fine. But it still does not call my functions. Which leads me to believe it's an html issue. Now, These functions work perfectly in firefox and IE. Chrome has to be the troublemaker in the litter and doesn't seem to want to work properly.
Here are my functions.
function default_h1() {
document.getElementById('showh1').innerHTML="<h1>Register to Play!</h1>";
}
function join_humans() {
document.getElementById('showh1').innerHTML="<h1 id=\"bluefont\">Join the Humans!</h1>";
}
function join_orcs() {
document.getElementById('showh1').innerHTML="<h1 id=\"redfont\">Join the Orcs!</h1>";
}
function human_factions() {
document.getElementById('show').innerHTML="<option value='Human Faction'>Human Faction</option>";
}
function orc_factions() {
document.getElementById('show').innerHTML="<option value='Orc Faction'>Orc Faction</option>";
}
function choose_faction() {
document.getElementById('show').innerHTML="<option value='empty_f'>*Choose</option>";
}
And here is the table and form with which uses these functions.
<tr>
<td><h5>Race:</h5></td>
<td class="top" colspan="2"><select name="race">
<option value="empty_r" onclick="choose_faction(), default_h1() ">*Choose</option>
<option value="Humans" onclick="human_factions(), join_humans()">Humans</option>
<option value="Orcs" onclick="orc_factions(), join_orcs()">Orcs</option>
</select><?php if (!empty($errors[7])) echo "$errors[7]"; ?>
</td>
</tr>
<tr>
<td><h5>Faction:</h5></td>
<td class="top" colspan="2"><select id="show" name="faction">
<option value="empty_f">*Choose</option>
</select><?php if (!empty($errors[8])) echo "$errors[8]"; ?>
</td>
</tr>
help! Chrome makes me sad =(
UPDATE
I discovered that this script actually doesn't work in IE either.. so something fishy is going on and it has to be something with the HTML that calls the functions
Upvotes: 1
Views: 105
Reputation: 848
Try using jquery.
Add id to all options.
And use id as selector and do the implimentation as that button is clicked
example
<option id="id" value="empty_r" >*Choose</option>
$("#id").click(function){
choose_faction();
default_h1();
}
Upvotes: 0
Reputation: 15490
use semicolons after method calling, and use Capital C in onClick
<option value="empty_r" onClick="choose_faction(); default_h1();">*Choose</option>
<option value="Humans" onClick="human_factions(); join_humans();">Humans</option>
<option value="Orcs" onClick="orc_factions(); join_orcs();">Orcs</option>
Upvotes: 3