Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript/Jquery file not loading
    primarykey
    data
    text
    <p>My Jquery works fine in-line however when I try and make it external it doesn't seem to work. I have both scripts stored in the: include('./includes/header.html'); And I also have them stored at the root of the folder.</p> <p>If any one could help would be great.</p> <p>I have two links held within the header.html</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;head&gt; &lt;title&gt; &lt;?php $page_title ?&gt; &lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="mystyle.css"&gt; &lt;script src="formValidation.js"&gt;&lt;/script&gt; &lt;script src="jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper"&gt; &lt;div id="header"&gt; &lt;h1&gt;Films.com&lt;/h1&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="nav"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="login.php"&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="register.php"&gt;Register&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="film.php"&gt;Film&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="add_film.php"&gt;Add a Film&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>When going to add_film.php the Jquery that would normally slide down my form, now it doesn't slide down.</p> <pre><code> &lt;?php include('./includes/header.html'); echo "&lt;h1&gt;Add A film&lt;/h1&gt;"; if(isset($_POST['submitted'])){ $errors = array(); // Initialize erroy array. // Check for title. if (empty($_POST['movie_title'])){ $errors[] = "You forgot to enter a title."; } else { $mn = (trim($_POST['movie_title'])); } // Check for leading actor if (empty($_POST['leading_actor'])){ $errors[] = "You forgot to enter the leading actor."; } else { $la = (trim($_POST['leading_actor'])); } // Check for a rating if (empty($_POST['rating'])){ $errors[] = "Please select a rating."; } else { $rating = ($_POST['rating']); } // Check for a review if (empty($_POST['review'])){ $errors[] = "Please write a review"; } else { $review = (trim($_POST['review'])); } if (empty($errors)) { // If no errors were found. require_once('./includes/Mysql_connect.php'); // Make the insert query. $query = "INSERT INTO films (movie_title, actor, rating) Values ('$mn', '$la', '$rating' )"; $result = mysql_query($query); $id = mysql_insert_id(); $query = "INSERT INTO reviewed (review, movie_id) values ('$review', '$id')"; $result = mysql_query($query); //Report errors. } else { foreach ($errors as $msg){ echo " - $msg &lt;br/&gt; "; } } } </code></pre> <p>?></p> <pre><code>&lt;html&gt; &lt;form action="add_film.php" method="post" id="add_film"&gt; &lt;fieldset&gt; &lt;label for="title"&gt;Movie Title&lt;/label&gt; &lt;input type="text" name="movie_title" id="movie_title" /&gt; &lt;br/&gt; &lt;br/&gt; &lt;label for="actor"&gt;Leading Actor&lt;/label&gt; &lt;input type="text" name="leading_actor" id="leading_name" /&gt; &lt;br/&gt; &lt;br/&gt; &lt;label for="rating"&gt;Rating&lt;/label&gt; &lt;select id="rating" name="rating"/&gt; &lt;option selected="selected" value=0 disabled="disabled"&gt;Select a Rating&lt;/option&gt; &lt;option value="Terrible"&gt;Terrible&lt;/option&gt; &lt;option value="Fair"&gt;Fair&lt;/option&gt; &lt;option value="Ok"&gt;Ok&lt;/option&gt; &lt;option value="Good"&gt;Good&lt;/option&gt; &lt;option value="Excellent"&gt;Excellent&lt;/option&gt; &lt;/select&gt; &lt;br/&gt; &lt;br/&gt; &lt;label for="review"&gt;Your Review&lt;/label&gt; &lt;br/&gt; &lt;textarea name="review" id="review" rows="15" cols="60"&gt;&lt;/textarea&gt; &lt;br/&gt; &lt;br/&gt; &lt;input type="submit" name="submit" id="submit" value="submit" /&gt; &lt;input type="hidden" name="submitted" value="TRUE" /&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;br/&gt; &lt;/html&gt; &lt;?php include('./includes/footer.html'); ?&gt; </code></pre> <p>Here is my Jquery.</p> <pre><code> $(document).ready(function(){ $('#add_film').slideDown(800); // Focus on first form field. $("input:text:visible:first").focus(); $('#add_film').submit(function (e) { var error = false; // No value for movie_title if ($('#movie_title').val() == "") { alert("No Film"); error = true; } // No Value for actor if ($('#leading_name').val() == "") { alert("No actor"); error = true; } // No value for rating if ($('#rating').val() == null) { alert("No Rating"); error = true; } //No value for review if ($('#review').val() == "") { alert("No review"); error = true; } if (error) { e.preventDefault(); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload