Reputation: 123
I'm trying to add a JavaScript code in tpl, but when I click the button, nothing happens. here is the code:
<script type="text/javascript">
// Hide optional fields
$("#hide_op").click(function() {
$("#optional_fields").hide("slow");
});
// Show optional fields
$("#show_op").click(function() {
$("#optional_fields").show("slow");
});
// Switch the a tags...
$("#toggle a").click(function() {
$("#toggle a").toggle();
});
</script>
That is the JavaScript code I want to use to drop down extra items; but nothing works. here is the button I'm using "
<div id="toggle">
<a id="hide_op" class="formcss1" style="margin-left: 0; display: none;" onclick="return false;" href="#">Hide optional fields</a>
<a id="show_op" class="formcss1" style="margin-left: 0;" onclick="return false;" href="#">Show optional fields</a>
</div>
Then I have the div codes for the java :
<div id="optional_fields" style="display: none;">
then it ends.
Upvotes: 0
Views: 5442
Reputation: 129
Try to add {literal} in start and end
<script type="text/javascript">
{literal}
// Hide optional fields
$("#hide_op").click(function() {
$("#optional_fields").hide("slow");
});
// Show optional fields
$("#show_op").click(function() {
$("#optional_fields").show("slow");
});
// Switch the a tags...
$("#toggle a").click(function() {
$("#toggle a").toggle();
});
{/literal}
</script>
Upvotes: 0