Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: getobject error retrieving data from mysql

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default getobject error retrieving data from mysql

    hello,

    i have java script below. i am retrieving states from mysql database and list them dropdown menu.
    oscommerce, mysql and php.

    this script works well when it is embedded between head tags to each php file in old version. goes to city_get.php and takes the state result from there. but in the new version (no head tags in php file) i saved the script as js file and try to call from template_top.php (which shows the all the java's way), explorer gives error in the below line. i have followed this error from explorer error messages.

    getObject("states").innerHTML = req.responseText;

    what is wrong with this?
    thx

    <?php
    /*
    $Id$
    osCommerce, Open Source E-Commerce Solutions
    osCommerce, Open Source Online Shop E-Commerce Solutions
    Copyright © 2003 osCommerce
    Released under the GNU General Public License
    */
    ?>
    <script type="text/javascript"><!--
    var req;
    function loadXMLDoc(key) {
    var url="city_get.php?ShptsiD=<?php echo tep_session_id();?>&country="+key;
    getObject("states").innerHTML = ' <img style="vertical-align:middle" src="images/loading.gif"> Pls hold...';
    try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e) {
    try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(oc) { req = null; }
    }
    if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }
    if (req != null) {
    req.onreadystatechange = processChange;
    req.open("GET", url, true);
    req.send(null);
    }
    }
    function processChange() {
    if (req.readyState == 4 && req.status == 200) {
    getObject("states").innerHTML = req.responseText;
    }
    }
    function getObject(name) {
    var ns4 = (document.layers) ? true : false;
    var w3c = (document.getElementById) ? true : false;
    var ie4 = (document.all) ? true : false;
    if (ns4) return eval('document.' + name);
    if (w3c) return document.getElementById(name);
    if (ie4) return eval('document.all.' + name);
    return false;
    }

    //--></script>


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: getobject error retrieving data from mysql

    Hey Zeberrun! I'm afraid Java and Javascript are different languages, and this is a Java forum.
    Although some of our members (though very little I imagine) might have some expertise in JavaScript, It is not guaranteed that they will be online when you need them.

    For a better chance of answers, I would advise you to go to a JavaScript dedicated forum.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

Similar Threads

  1. saving data in persian language in mysql db
    By java_cs in forum JDBC & Databases
    Replies: 2
    Last Post: January 19th, 2011, 12:26 PM
  2. [SOLVED] Passing data to a MySQL database
    By JDyson in forum JDBC & Databases
    Replies: 1
    Last Post: December 1st, 2010, 01:31 PM
  3. [SOLVED] Get Data From Database MySQL using ComboBox
    By Simple in forum Java Theory & Questions
    Replies: 2
    Last Post: June 4th, 2010, 02:45 AM
  4. Retrieving Meta-Data from a File
    By FretDancer69 in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: February 9th, 2010, 08:10 AM
  5. problem in retrieving data via RMS
    By solaleh in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: August 30th, 2009, 05:46 AM