Solved

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

Posted on 2010-08-17
6
2,029 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 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