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
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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.