Results 1 to 4 of 4

Thread: Simple JS Help

  1. #1
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default Simple JS Help

    I need to pass a variable on through a URL in javascript

    Code:
    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?

  2. #2
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    document.getElementById('image').src = 'foo';
    kinda quit.

  3. #3
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    but I need the innerHTML to be <img src='theurldefinedintest'>

  4. #4
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    document.getElementById('image').innerHTML = '<img src="'+test+'" />';
    kinda quit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •