Jump to content

[SOLVED] Pass Java Variable to php


dizzy1

Recommended Posts

I type a word in a text box and in a <div> tag the results appear of what ive just typed so i can then check if the username exists. THIS WORKS.

 

However it messes up my entire page which is made entirely out of <div> tags, please help its 7.13am and ive been trying to fix it since 11pm.

 

JS

var xmlHttp;
function checkUser(str){ 

xmlHttp=new XMLHttpRequest();
var url="test.php";
url=url+"?v="+str;

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState == 4)
{ 	 
document.getElementById("Result").innerHTML=xmlHttp.responseText;  
} 
}

 

 

php


echo"<div id='Result'>";

$v=$_GET["v"];
$v = trim($v);

        echo"THE TEXTBOX VALUE IS: $v";

        echo"</div>";

 

Is thier any other way i can do this so the <div> tags dont mess up my entire page.

Link to comment
https://forums.phpfreaks.com/topic/147531-solved-pass-java-variable-to-php/
Share on other sites

I always use indecisive tags like <span id="yourid"> </span> or even paragraphs <p id="yourid"> , there are alot of options, but you need to make sure you javascript isn't LOOKING for a div, if it is then you would need to change it as well.

 

Mate ive tried table, p and span, ive even tried puttin it into a textbox but its seems to display every div again so it appears twice overlapping the original and messing up my screen, any other ideas. is it possible to display my results in another page and have that updated, gonna try do it using an include.

K wot i did was used the <div> tags so it was where i wanted it displayed i did:

 

 

<div id='Result'></div>

 

Then i made another page which was diffrent from the page which displays all the content testValuepassed.php and put the basic stuff in their.

 

works perfectly

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.