Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    10
    Thanked 0 Times in 0 Posts

    external js not loading with php switched div

    Hi all,

    I have a page with a couple of navigation buttons.
    the buttons are used to load and external page into the div using a php script
    the scripts used case 1 case 2 case 3 etc. It works.

    The problem is that my otherwise working Java Script does not work or load with this set up. it is an external .js file that i call in the header of the base page.

    Is there a reason that it will not load properly now?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Post your code, or a link to your page would be better.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    10
    Thanked 0 Times in 0 Posts

    The code

    Of course sorry here is the code

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
    <head>
    <title>Contact Information</title>
    <meta http-equiv="Content-Style-Type" content="text/html; charset=ISO-8859-1">
    <script type="text/javascript" src="http://www.website.com.au/js/contact.js"></script>
    <script type="text/javascript" src="http://www.website.com.au/js/template.js"></script>
     
    <link rel="stylesheet" href="http://www.website.com.au/css/contact.css" type="text/css" media=screen>
    <link rel="stylesheet" href="http://www.website.com.au/css/contact_info.css" type="text/css" media=screen>
    <? 
    switch ($_GET['page']) 
    {
    case "main": include ('http://www.website.com.au/contact_info.php'); break;
    case "2": include ('http://www.website.com.au/contact_email.php'); break;
    case "3": include ('http://www.website.com.au/contact_map.php'); break;
    case "4": include ('http://www.website.com.au/contact_aboutus.php'); break;
    case "5": include ('http://www.website.com.au/contact_feedback.php'); break;
    case "6": include ('http://www.website.com.au/contact_refer.php'); break; 
    
    default: include ('http://www.website.com.au/contact_info.php'); break;
    }
    ?> 
    </head>
    <body bgcolor="#GGGGGG" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
     <div id="table_contact">
        <div id="cftemplate"><? include("http://www.website.com.au/template.php"); ?></div>
        <div id="cfcontact-template"><? include("http://www.website.com.au/contact_template.php"); ?></div> 
        
    <? 
    switch ($_GET['page']) 
    {
    case "main": include ('http://www.website.com.au/contact_info.php'); break;
    case "2": include ('http://www.website.com.au/contact_email.php'); break;
    case "3": include ('http://www.website.com.au/contact_map.php'); break;
    case "4": include ('http://www.website.com.au/contact_aboutus.php'); break;
    case "5": include ('http://www.website.com.au/contact_feedback.php'); break;
    case "6": include ('http://www.website.com.au/contact_refer.php'); break; 
    
    default: include ('http://www.website.com.au/contact_info.php'); break;
    }
    ?>    
    </div>         
    </body>
    </html>

    NB the included template file has the nav buttons which change the case

    And here is one of the case included pages


    Code:
    <!-- Email Section -->
    <div>
    <form name="emailform" id="emailform" method="post" action="http://www.website.com.au/contact_email_sendmail.php">  
        <div><input class="email-name" type="text" size="30" maxlength="50" name="ename" value="your name" onfocus="value=''"></div>
        <div><input class="email-email" type="text" size="30" maxlength="50" name="eemail" value="your email address" onfocus="value=''"></div>
        <div><input class="email-subject" type="text" size="30" maxlength="50" name="esubject" value="subject" onfocus="value=''"></div>
        <div><textarea id="email-textarea" name="ebody" onfocus="value=''" rows="0" cols="0" onkeydown="limitText(this,400);" onKeyUp="limitText(this,400);"></textarea></div>
        <div id="email-sendmessage"><input type="image" name="esubmit"><a href="javascript: emailsubmit()" onclick="return emailvalidate()"></a></div>
    </form>
    </div>
        <div id="email-details"></div>
        <div id="email-rollaway" onmouseout="emailout()"></div>
    <!-- End Email Section -->

    And here is the linked java script file

    Code:
    /*-------- Email -----------------------------------------*/
    /*--- Email out---*/  
    function emailout() {
    if (document.emailform.ename.value.length == 0){
     document.emailform.ename.value="your name";
     return false; 
     }
    if (document.emailform.eemail.value.length == 0){
     document.emailform.eemail.value="your email address";
     return false; 
     }
    if (document.emailform.esubject.value.length == 0){
     document.emailform.esubject.value="subject";
     return false; 
    }    
     return true;
    }
    
    /*-- Email submit---*/  
    function emailsubmit(){
            document.emailform.submit();
        }
         
    /*-- Email validate---*/     
    function emailvalidate() {
            if (document.emailform.eemail.value.length < 5) {
    
                alert("Please enter your email address");
                document.emailform.eemail.focus();
                return false;
            }
            if (document.emailform.eemail.value.indexOf('@') == -1) {
                alert("Your E-Mail address does not appear to be valid");
                document.emailform.eemail.focus();
                return false;
            }
            if (document.emailform.eemail.value.indexOf('.') == -1) {
                alert("Your E-Mail address does not appear to be valid");
                document.mailform.eemail.focus();
                return false;
            }
            if (document.emailform.esubject.value.length < 4) {
                alert("Please enter a meaningful subject");
                document.emailform.esubject.focus();
                return false;
            }
            if (document.emailform.esubject.value == 'subject') {
                alert("Please enter a meaningful subject");
                document.emailform.esubject.focus();
                return false;
            }
            if (document.emailform.ebody.value.length < 15) {
                alert("Please enter a meaningful body");
                return false;  
            }
            if (document.emailform.ename.value.length < 1) {
                alert("Please enter your name");           
                document.emailform.ename.focus();
                return false;  
            }
            if (document.emailform.ename.value == 'your name') {
                alert("Please enter your name");
                return false;  
            }
        return true;
        }
    Last edited by Bambam007; 10-03-2008 at 08:38 AM. Reason: missed bracket

  • #4
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Also note that when I had the cases as separate pages (no case switching) the javascript was working

  • #5
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    10
    Thanked 0 Times in 0 Posts
    OMG I'm a huge silly person.

    I called the script twice!, no wonder it wasn't working. But thank you anyway because without showing you i may not have fixed it!


    Phew

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    lol! You're welcome (to Codingforums.com too )
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Bambam007 (10-16-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •