1

I have tried with this code, but it wont work. it works fine when i write it to onmouseover event.

echo CHtml::link('Form', 
          array('id'=>'submitButton'),
          array('class'=>'linkClass','onclick'=>'formSubmit();'))


//Javascript
echo CHtml::script("
    function formSubmit(){
         $('#supplier-form').submit();
}");

2 Answers 2

1

Try writing javascript code inside the script tags:

<script>
 function formSubmit(){
     $('#supplier-form').submit();
 }
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

after hours of searching finally found the answer. just add return false inside onclick event after you call function name.

array('class'=>'linkClass','onclick'=>'formSubmit(); return false;'))

and javascript function should be inside <script> tags as rdanusha mentioned

<script>
function formSubmit(){
 $('#supplier-form').submit();
}
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.