Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19248

Re: trying to call onclick with document.getElement() - document.getElement() returns null

From Mikael Andersson <qubex2@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: trying to call onclick with document.getElement() - document.getElement() returns null
References <17650677-77bd-4bca-8e10-ed45772f2e9f@googlegroups.com>
Date 2013-04-12 21:31 +0200
Message-ID <87fvyv1r7q.fsf@gmail.com> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


jorythompson@gmail.com writes:

[snip]
> *****************************************************************************
> <?php
>   require($_SERVER['DOCUMENT_ROOT'].'/../cgi-bin2/db.php');
>   function showCitiesCombo($name) {
>     $result = mysql_query("SELECT distinct city FROM Lot ORDER BY city");
>     echo 'Select a City:<br>';
>     echo '<select name="' . $name . '" multiple>';
>       echo '<form>';
>         while($row = mysql_fetch_array($result)) {
>           if ($row['city'] != "") {

[snip]
>     <script>
>       function searchForLots() {
>         street = document.getElementById('street');
>         city = document.getElementById('cities');
>         state = document.getElementById('state');
>         
>         if (window.XMLHttpRequest) {
>           // code for IE7+, Firefox, Chrome, Opera, Safari


Hi,

You should either use document.getElementsByName('street'), which
returns an array. Or change the select to: (you can in php write)

echo "<select name='$name' id='$name'>";
                           ^^
easier to read and understand. When using " double quotes you can have
php variables inside.

Yours,
QubeX2

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

trying to call onclick with document.getElement() - document.getElement() returns null jorythompson@gmail.com - 2013-04-12 10:45 -0700
  Re: trying to call onclick with document.getElement() - document.getElement() returns null Jordan Thompson <jorythompson@gmail.com> - 2013-04-12 11:01 -0700
  Re: trying to call onclick with document.getElement() - document.getElement() returns null Mikael Andersson <qubex2@gmail.com> - 2013-04-12 21:31 +0200
    Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 10:29 +0200
      Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-13 11:10 +0200
        Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 11:45 +0200
          Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-13 13:04 +0200
            Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 13:26 +0200
              Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-13 21:12 +0200
                Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 21:31 +0200
                Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-16 20:01 +0200
                Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-16 23:13 +0200
      Re: trying to call onclick with document.getElement() - document.getElement() returns null Mikael Andersson <qubex2@gmail.com> - 2013-04-13 18:35 +0200

csiph-web