PDA

View Full Version : Simple JS Help



Dentafrice1
14-02-2007, 12:27 PM
I need to pass a variable on through a URL in javascript


function createRequestObject(){
var request_;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_ = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
request_ = new XMLHttpRequest();
}
return request_;
}
var http = createRequestObject();
function getInfo(){
http.open('get', 'test2.php?username='
+ document.forms[0].message.value);
http.onreadystatechange = handleInfo;
http.send(null);
}
function handleInfo(){
if(http.readyState == 4){
var response = http.responseText;
test = 'http://imager.ffwbmarion.com/sample.php?text='+ document.forms[0].message.value;
document.getElementById('image').innerHTML = test;

}
}

Down there where it selects the div image. I need it to be

<img src=testurl> but I cant figure out how to put that variable test in an image tag.. any ideas?

nets
14-02-2007, 12:42 PM
document.getElementById('image').src = 'foo';

Dentafrice1
14-02-2007, 11:35 PM
but I need the innerHTML to be <img src='theurldefinedintest'>

nets
15-02-2007, 02:26 PM
document.getElementById('image').innerHTML = '<img src="'+test+'" />';

Want to hide these adverts? Register an account for free!