JS web function not working on client side - PHP-JS-HTML

I have this code:

...     <tr id="hidden-row">	
		<td colspan=7>
			<a id="addrow" href="javascript:;" title="Add a row">Add a row</a>
			<button onclick="addarow()">Add a row</button>

With this script:

function addarow() {
	var table = document.getElementById("table-items");
	var row = table.insertRow(0);
	var cell1 = row.insertCell(0);
	var cell2 = row.insertCell(1);
	var cell3 = row.insertCell(2);
	var cell4 = row.insertCell(3);
	var cell5 = row.insertCell(4);
	var cell6 = row.insertCell(5);
	var cell7 = row.insertCell(6);
$(document).ready(function() {   
    $(".item-row:last").after('<tr class="item-row"><td>#</td><td>New Item</td><td>New</td><td>New</td><td>New</td><td>New</td><td>New</td></tr>');

The button and link, do the same thing.
Here is the problem, when I test it in localhost, the button and link works fine but when I test it from a different PC, the link is not working and is the one I need to work. Any idea what can be the root cause? do I need extra permissions in my host or add an extra line of code? I am not very savvy with JS. Thank you in advance.
Try different browsers and nothing, the link Add a row does nothing.

PHP, javascript, html, js

How is your folder setup icm with your link to the javascript in your html?

folder setup:

         layout.php(reference to js from here)
            quote.php (using and referencing js from here)

From layout.php:
<script type="text/javascript" src="js/script.js"></script>

From quote.php:
<script type="text/javascript" src="..\js\script.js"></script>

sounds like the paths of your files are not correct.

You can use the dev tools (f12) of your browser, then in the network tab you can see which files are loaded/found. If you see a 404 for a JS file, you know you didn’t specify the path correctly.

also, i would use forward slashes in paths. Both Linux, macOS and windows can handle that. Backslashes only work on windows.

1 Like

Thank you, you were right, files were not being loaded