Anybody know why :onchange works here...
<%= select_tag "Minisections",
options_from_collection_for_select(@minisections, :id, :title, :selected
=> @minisection.id), {:onChange => "{alert('Minisection has been changed
to x !')}"} %>
but NOT here (to call a function)...
<script type="text/javascript">
function xyz() {
"{alert('Minisection has been changed to x !')}"}
</script>
Visit your rendered page in a browser, view source, and copy all. Then go to http://validator.w3.org and use the Direct Input tab and paste. Validate your page. If it passes there, then enable Firebug in your copy of Firefox, open up the console section, and visit your page. You either have an HTML/DOM error or a JavaScript error. Once you figure out which one you're dealing with in this case, you can proceed to a fix.
Anybody know why :onchange works here...
<%= select_tag "Minisections",
options_from_collection_for_select(@minisections, :id, :title, :selected
=> @minisection.id), {:onChange => "{alert('Minisection has been changed
to x !')}"} %>
but NOT here (to call a function)...
<script type="text/javascript">
function xyz() {
"{alert('Minisection has been changed to x !')}"}
</script>
Because all that function does is create a string literal - it's not
actually calling alert because all that is enclosed in "".
I am trying to learn Rails, HTML, Javascript, and Ajax but am learning
on my own. No programming background. I spent a couple of days trying
to figure this out before asking the question, and did Google it . Been
working on this project for over a year (maybe longer) and have only
asked for help a few times. Up till your reply, everyone has been very
helpful.
Heya Dave - do not let the trolls scare you - we are all beginners at some point - asking queations will help you learn and progress. web apps are a complex beast