tags:

views:

53

answers:

5

Hi I have written a abcd.ftl page which is beeing called in another defg.page The abcd.flg page has the fallowing code

 <div class="partnerOptInBox">
     <div id="optInContent">
      <form name="partnerOptIn">
       <h4>Want the Latest</h4>
       <p class="pad10Top">${partnerOpt.translation}</p>
       <div class="pad10Top">
       <input type="radio" name="questionAnswer['${partnerOpt.questionId}']" value="${partnerOpt.getAnswers()[0].answerId}" class="radioButton" /> <label for="questionAnswer['${partnerOpt.questionId}']" class="formLabel pad20Right">Yes</label> <input type="radio" name="questionAnswer['${partnerOpt.questionId}']" class="radioButton" value="${partnerOpt.getAnswers()[1].answerId}" /> <label for="questionAnswer['${partnerOpt.questionId}']" class="formLabel">No</label>
       </div>
       <div id="optInError" class="formError" style="display:none;">Oops... your request did not go through, please try again.</div>
       <div class="pad15Top">
        <a href="javascript:submitOptIn();"><img src="images/theme/btn_opt_in_submit.gif"/></a>
       </div>                        
      </form>
      <script type="text/javascript">
function submitOptIn() {
    $('optInError').hide();
    dataString = $('#partnerOptIn').serialize();
    $.ajax({
     data: dataString,
     url: partnerOpt.do,
     timeout: 30000,
     type: "POST",
       success: function(html){
            var newHtml = "<h4>Thank you</h4><p>We appreciate your time to respond to our request.</p>";
            $('#optInContent').html(newHtml);
    },
     error: function(){
      $('#optInError').show();
     }
    });
}
</script>

     </div>
    </div>

But when I am clicking the submit button on this page its throwing a error saying "javascript:submitOptIn" not defined can any one please let me know what would be the reason for this error asap please THank you

A: 

I think that you should put the script tag in the head of the page.

mck89
A: 

Doesn't javascript have to be enclosed in {literal}?

RD
A: 

try:

<a href="#" onClick="javascript:submitOptIn();">...</a>
x2
-1: No need to put the js in onclick.
Mickel
A: 

All jQuery scripts should be placed inside the "document.load" event to ensure that the DOM has loaded. Try to place your scripts inside:

$(function() {

   // place your scripts here

});
Mickel
A: 

The code DOES work on IE6, IE7, FF and Chrome...
It's all the code you posted in the defg.page, or are you calling it from the abcd.ftl page?

seize
the defg page is the parent page where I wrote something like <#include "abcd.ftl">