R-click first div box and INSPECT ELEMENT why not applied .b3choosen class when click

i used something like

document.getElementById("b1br").onclick = function () {
     document.getElementById("b1br").className += " MyClass2";
}

i used this after page loads but does not work? b1br element is above onclick assignment, well?

go here www.poliscarhire.com try book car when reach www.poliscarhire.com/customeradmin/booking-review.php study source, the blue clickable divs are the ones mentioned, well? why no change??? R-click first div box and INSPECT ELEMENT why not applied .b3choosen class when clicked?

Hi,

You can write that:

document.getElementById("b1br").onclick = function () {
     document.getElementById("b1br").className += " MyClass2";
}

Like this:

document.getElementById("b1br").onclick = function () {
     this.className += " MyClass2";
}

Regarding your question, when I look at the Dev Console in Chrome I see:

Uncaught TypeError: Cannot set property 'onblur' of null validationAJAXreadyBOOKnoAcYesAcNew.js:11

which is probably stopping any further scripts from executing.
Either way, you’ll want to get this fixed first.

Either way, you’ll want to get this fixed first.

onblur is applied to an element that appears dynamically with php when click SOCIAL REGISTER where you return after some secs to this page… what the solution, include onblur js code inside php (html) block?

Can you try commenting it out for the time being, to see if that makes a difference to your initial problem.

i get another non in js file but in js embedded in php file…

Sorry, I meant comment out line 11 in the file validationAJAXreadyBOOKnoAcYesAcNew.js

This is:

document.getElementById("email").onblur = checkUsername;

i did exactly that but got what is screenshoted…

Oh dear.

You need to comment out two lines in your initPage9 function

document.getElementById("email").onblur = checkUsername;
document.getElementById("usernameLoading").style.display = "none";

Both of these lines try to reference an element which doesn’t exist on load, so they are superfluous anyway.

If you dynamically add these elements according to how the user interacts with your page, you could always just check first to see if they exist first:

var email = document.getElementById("email");
if(email !=null){
  email.onblur = checkUsername;
}

var unameLoading = document.getElementById("usernameLoading");
if (unameLoading !=null){
  unameLoading.style.display = "none";
}

Hope that helps.

i did replace code but got two new identical exactly error in js :

“Uncaught TypeError: Cannot read property ‘style’ of null”

js embedded this time here >>>

http://www.poliscarhire.com/customeradmin/booking-review.php

As i noticed these error non shown in chrome > when the php generates the code and this when press SOCIAL REGISTER > return to page itself (prior press to register(insert more data prior press required)) > page no errors…well?

also note during php code inject on page:

i eject also the below code

in dw line of php 18090line

	<script type="text/javascript">
			document.getElementById("b3br").className += " b3choosen";
			
			document.getElementById("b1br").className = "";
			document.getElementById("b1br").className += "b3";
			
			document.getElementById("b2br").className = "";
			document.getElementById("b2br").className += "b3";		
	</script>

Hi there,

I looked at the page you link to, but cannot see any JS errors.
I do see two 404 errors for a png anda gif file, but these won’t be affecting much.

I’m not too sure what you mean here, but the lack of errors are probably down to the fact that clicking on “SOCIAL REGISTER” inserts the missing elements (email and usernameLoading) into the page.

I’m not sure what you mean by eject and why you would want to remove this code.

The best advice I can give you now is to try and make a page where we can reproduce the error without having to click on this, do that, go back to the previous page etc.
I appreciate the fact that this must be frustrating, but it is the only way we are going to be able to bring this forward.

“I looked at the page you link to, but cannot see any JS errors.” press 1st or second blue div button to see embedded js errors…
when press 3rd blue div
" the missing elements (email and usernameLoading) into the page." but fixed problem with
with social register press=eject php no error,…
var email = document.getElementById(“email”);
if(email !=null){
email.onblur = checkUsername;
}

var unameLoading = document.getElementById(“usernameLoading”);
if (unameLoading !=null){
unameLoading.style.display = “none”;
}

Hi there,

I’m sorry, but I don’t really know what else I can tell you here.
The error is caused by the fact that you are trying to set the style property of an element that doesn’t exist in the DOM.

You can get around it like this:

var elementToTestFor = document.getElementById("elementID");

elementToTestFor should now either be the element or null, so:

if (elementToTestFor != null){
  // Code here when the Element Exists.
}