I’ve got a pretty simple javascript function that is called when you click a button. The script pulls a value from a dropdown box on the page and uses that value to determine what text to plug into a textarea text box. The script runs perfectly for all options the first time you click the button. However, if you click the button again nothing happens. I don’t even get an error message in the Web Developer add-on in FireFox. It seems as though it’s not even running the script. Any ideas?
HTML Code:
[CODE]
<select id=”drpCodeTemplates” name=”drpCodeTemplates” size=”1″ tabindex=”11″>
<option selected value=”NA”></option>
<option value=”Featured”>Featured</option>
<option value=”RSS”>RSS</option>
</select>
<input type=”button” name=”CodeTemplatesButton” value=”Add Code” tabindex=”12″ onclick=”AddCode();”>
<textarea name=”txtDefinition” id=”txtDefinition” rows=”15″ cols=”95″ tabindex=”13″><% Response.Write Server.HTMLEncode(strDefinition) %></textarea>
Javascript Code:
[CODE]
function AddCode(){
var strCodeTemplate = document.getElementById(“drpCodeTemplates”).value;
var strDefinition = document.getElementById(“txtDefinition”).value;
if(strDefinition.length == 0){
switch(strCodeTemplate){
case “Featured” :
document.getElementById(“txtDefinition”).innerHTML = “Featured”;
break;
case “RSS” :
document.getElementById(“txtDefinition”).innerHTML = “RSS”;
break;
default :
if(strCodeTemplate == “NA”){
document.getElementById(“txtDefinition”).innerHTML = “Code Template Operation Failed. DeeDeeDee! You have to choose a template for this to work!”;
}
else{
document.getElementById(“txtDefinition”).innerHTML = “Code Template Operation Failed. Please inform the webmaster.”;
}
}
}
else{
alert(“You must first delete all text from the Definition text box in order to add a code template”);
}
}