Solved

Internet Explore problem - Cakephp  $form->submit with onclick function

Posted on 2010-08-17
6
2,038 Views
Last Modified: 2013-11-10
Hi All,

I have a cakephp application
Pls check the following code in the ctp file listed below:-
<script>
function validate()
{
//some code
return false;
}
</script>
<?php
echo $form->submit("images/but_save.jpg", array( "alt" => "Save",'onclick'=>'javascript:return validate()','width'=>'80','height'=>'25', 'url' => "edit/", 'update' => array('dynamic2', 'dynamic3')));
?>
its working in firefox,oper etc, but not in Internet Explore, what is the issue?
No javascript error occures!.

Thanks in advance.
0
Comment
Question by:Web_Sight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:Snarfles
ID: 33452473
I'm not familiar with cakephp...

We cannot assume that the validate function is working properly, especially with ie. Can you provide the code for this rather than just '//some code'.

Alternatively the best way to debug some javascript code is to use alerts

alert(variable_name);

Cheers
0
 

Author Comment

by:Web_Sight
ID: 33452560
the code is listed below:-
if(document.getElementById('SupportOprequired')!=null)
    {
        var val= document.getElementById('SupportOprequired').value;
        if(val=="Yes")
        {
            if(trim(document.getElementById('SupportPonumber').value)=="")
            {
                alert("Must have PO Number from the customer before you can save the call.");
                document.getElementById('SupportPonumber').value = trim(document.getElementById('SupportPonumber').value);
                document.getElementById('SupportPonumber').focus();
                return false;
            }
            else
                document.getElementById('SupportPonumber').value = trim(document.getElementById('SupportPonumber').value);

        }

    }
0
 
LVL 9

Accepted Solution

by:
Snarfles earned 500 total points
ID: 33452660
Make sure that your elements have a name attribute as well as an id attribute.

eg id="SupportPonumber" name="SupportPonumber"

There is a bug with ie7 and ie6 where it takes the name attribute rather than the id attribute for getElementById

a bit typical isnt it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Web_Sight
ID: 33452744
Hi,
But the browser is ie8
0
 
LVL 9

Expert Comment

by:Snarfles
ID: 33452861
Do you have a url I could look at?
0
 

Author Closing Comment

by:Web_Sight
ID: 33602740
good
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question