Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1026169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:02:29+00:00 2026-05-16T12:02:29+00:00

How can i import javascript in php? No matter what i try, i can’t

  • 0

How can i import javascript in php? No matter what i try, i can’t seem to get the buttons in my page to trigger the events in javascript.

This is my javascript file content:

function addRow(tableID) {

 var table = document.getElementById(tableID);

 var rowCount = table.rows.length;
 var row = table.insertRow(rowCount);

 var colCount = table.rows[0].cells.length;

 for(var i=0; i<colCount; i++) {

  var newcell = row.insertCell(i);

  newcell.innerHTML = table.rows[0].cells[i].innerHTML;
  //alert(newcell.childNodes);
  switch(newcell.childNodes[0].type) {
   case "text":
     newcell.childNodes[0].value = "";
     break;
   case "checkbox":
     newcell.childNodes[0].checked = false;
     break;
   case "select-one":
     newcell.childNodes[0].selectedIndex = 0;
     break;
  }
 }
}

and

function deleteRow(tableID) {
 try {
 var table = document.getElementById(tableID);
 var rowCount = table.rows.length;

 for(var i=0; i<rowCount; i++) {
  var row = table.rows[i];
  var chkbox = row.cells[0].childNodes[0];
  if(null !== chkbox && true === chkbox.checked) {
   if(rowCount <= 1) {
    alert("Cannot delete all the rows.");
    break;
   }
   table.deleteRow(i);
   rowCount--;
   i--;
  }

 }
 }catch(e) {
  alert(e);
 }
}

This is how i try to import it in a php file:

       <HEAD>
 <script src="myfile.js" type="text/javascript"></script>
</HEAD>

what am i doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:02:30+00:00Added an answer on May 16, 2026 at 12:02 pm

    Open up the page in Firefox. Right click the page and select the option to show the sourcecode. Find the script tag and click the linked src. If it gives you a 404, the link is wrong. If it shows your JS code, it’s fine. Install Firebug for Firefox and debug your code with it. Make sure your Event Listeners actually get triggered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I include/import javaScript file/libary in xslt file.
A user can import data into our website from a file. The data normally
I have a page where a user can import data to the site. either
After I installed MySQLdb by sudo apt-get install python-mysqldb I can import and use
How can I import a database with MySQL from terminal? the syntax from this
How can I import a CSV file into a MySQL table? I would like
I know JavaScript is client side and PHP is server-side. I also know this
The problem: I want to use PHP include to import file header_menu.html into all
I try to init DataTable but can't. <style type=text/css title=currentStyle> @import demo_page.css; @import demo_table.css;
I read that, for the newest Java, Javascript on Java can call or import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.