Vote count:
0
Here's my code:
<script LANGUAGE="Javascript">
function choiceReturn(obj) {
switch(obj.value) {
case "1":
document.write("<input value='Fund (L###)' type='text'
class='button3' onfocus='if(this.value == "Fund (L###)"){this.value = '';}'
onblur="if(this.value == ''){this.value = 'Fund (L###)'}">");
}
}
</script>
<select name="funds_menu" onchange="choiceReturn(this);">
<option selected>Choose 1 to 3</option>
<option value="1">1. Choose fund</option>
<option value="2">2. Prepare data</option>
<option value="3">3. Perform valuation</option>
</select>
My intention: Upon selecting the first item from the list, the Fund (L###) input box appears. I also have some minor code onblur and onfocus to make this a bit cooler.
However, nothing happens. What am I doing wrong? There's a lot of quotation marks there. Perhaps that's what's messing this up.
asked 1 min ago
1 Answer
Vote count:
0
Multiline strings aren't a thing in JavaScript. You're going to have to concatenate them separately. Furthermore, some of your nested nested strings aren't escaped properly. Fixed code:
document.write("<input value='Fund (L###)' type='text' " +
"class='button3' onfocus='if(this.value == \"Fund (L###)\"){this.value = '';}' " +
"onblur='if(this.value == \"\"){this.value = \"Fund (L###)\"}'>");
answered 5 secs ago
Aucun commentaire:
Enregistrer un commentaire