0

i have the code below on a live site. what the form button is suppose to do is transfer the parameters to a .js file and send it to the model for insertion. but the code/form wont just allow or read the .js file

<form id="contactform" name="contactform">
  <div class="contact-form-txt"> Contact Form</div>
  <p>
    <label for="name">Full Name *</label>
    <input id="name" type="text" name="name" required="">
  </p>
  <p>
    <label for="company">Company Name</label>
    <input id="company" type="text" name="company" required="">
  </p>
  <p>
    <label for="phone">Phone Number </label>
    <input id="phone" type="text" name="phone" required="">
  </p>
  <p>
    <label for="email">Email Address *</label>
    <input id="email" type="text" name="email" required="">
  </p>
  <p>
    <label for="profile">Question</label>
    <textarea name="profile" id="profile" required=""></textarea>
  </p>
  <button id="submit">Submit</button>
  <!-- <button> submit </button> -->
</form>

the loading contact.js file is in the header file. `

    <script type="text/javascript" src="<?php echo URL ?>/public/js/contact.js"></script>`

and the jquery file that i want to load is..

$(document).ready(function() {
      alert("plssssss");
      $(document).on("click", "#submit", function(event) {
      });
});//document ready
7
  • check your console (F12) and see if there is some error shown Commented Apr 28, 2016 at 12:03
  • you are missing }); also missing the jquery file Commented Apr 28, 2016 at 12:03
  • is URL a constant or a variable, if variable it need dollar at the begnning and echo need semicolon at the end. Commented Apr 28, 2016 at 12:05
  • missing }); seems like a typo. Still, first thing you need to do is check your console (F12). Commented Apr 28, 2016 at 12:05
  • did you add jquery js to your page? Commented Apr 28, 2016 at 12:06

3 Answers 3

1

I think you forgot to add jQuery library.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
   alert("hello");
});
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

The javascript should be

$(document).ready(function() {
  alert("plssssss");
  $(document).on("click", "#submit", function(event) {});
});

1 Comment

have re-adjusted it still not changes.
0

the jQuery should be:

$(document).ready(function() {
      alert("plssssss");
      $(document).on("click", "#submit", function(event) {});
});

1 Comment

@sambayour if my solution helped you, please set as your solution or at least click on the upper arrow. ;)

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.