By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

query using textbox value selected

100+
P: 110
Hi,
I'm using scriptaculous autocomplete for my text box and it works perfectly ok
i have made server.php for fetching the values in the ul list and it is shown correctly on the main form but after selection of the value from the text box i want to query my database further for some more details depending on that value

but i don't get any records although my table has records.
if i alert ar values in showcode function it shows rows with values correctly but doesnt show int he div container
if itry to create that table in the main form taking the values of $c_cde it and then create rows of the existing data it doesnt show any rows
instead of generating the rows int he server.php
because it doesnt get $c_Cde value there i checked alerting it


where am i going wrong
my code goes here
[PHP]<form method="get">
<table id="tbl">
<tr>
<td bordercolor="#669999">
<label><strong><font size="3">Select country</strong></label></td>
<td colspan="11" bordercolor="#669999">
<input type="text" c_name="c_name" id="c_name" size="40" class="dlight" autocomplete="off" onblur="showCode(this.value);">
<div id="hint"></div>
<script type="text/javascript">
new Ajax.Autocompleter("c_name","hint","server.php");
</script>
<input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" >
<div id="tbl1"></div>
<tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
<td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
</table>
</form>[/PHP]

and my server.php if as follows


[PHP]<?php
include("../include/con.php");
$sql = "select c_code,c_name from countrymaster where c_name like '%" . $_GET['c_name'] . "%'";
$rs = $DB_site->query($sql);
?>
<ul>
<? while($data = $DB_site->fetch_array($rs)) { ?>
<li><? echo stripslashes($data['c_name']."-".$data['c_cde']);
?></li>
<? } ?>
</ul>
<?
if($_GET['c_name']!=""){
$mc_name=$_GET['c_name'];
$mc_cde=$_GET['c_cde'];
echo "|".$mc_cde."|";
}
$sql1="select * from countrydetails where c_cde='".$mc_cde."'";
$db_query_pricelist=$DB_site->query($sql1);
while($rs=$DB_site->fetch_array($db_query_rs)){
$misdcode=$rs[isdcode'];
$mcontinent=$rs['continent'];
?>
<tr><td><?=$misdcode;?></td>
<td><?=$mcontinent;?></td>
</tr>
<? } ?>[/PHP]





in showcode function
Expand|Select|Wrap|Line Numbers
  1. function showCode(str){ 
  2. c_name=str.substr(0,str.indexOf("-"));
  3. c_cde=str.substr(str.indexOf("-")+1);
  4.     xmlHttp=GetXmlHttpObject();   
  5.     if (xmlHttp==null){
  6.          alert ("Browser does not support HTTP Request");
  7.          return;
  8.      }
  9.     var url="server.php"; 
  10.     url=url+"?c_cde="+c_cde+"&c_name="+c_name;    url=url+"&sid="+Math.random(); 
  11.     xmlHttp.onreadystatechange=function(){stateChanged()} ; 
  12.     xmlHttp.open("GET",url,true);  
  13.     xmlHttp.send(null);
  14. }
  15.  
  16. function stateChanged() { 
  17. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  18.  { 
  19.     var ar=xmlHttp.responseText.split("|");
  20.    al=ar.length;
  21.    document.getElementById("c_cde").value=ar[1] ;
  22.       document.getElementById("tbl1").innerHTML=ar[2] ;
  23.    }
  24. }
Oct 3 '07 #1
Share this Question
Share on Google+
30 Replies


dmjpro
100+
P: 2,476
Is your PHP page returning the values as running separately?

Kind regards,
Dmjpro.
Oct 3 '07 #2

100+
P: 110
yes
country code and country name are shown in the php main program in the text box

but if i try to query after that in the same program taking country code it doesnt fetch any records
Oct 3 '07 #3

dmjpro
100+
P: 2,476
yes
country code and country name are shown in the php main program in the text box

but if i try to query after that in the same program taking country code it doesnt fetch any records
Well.

Expand|Select|Wrap|Line Numbers
  1. function stateChanged() {
  2. if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete") && xmlHttp.status==200)
  3.  {
  4.     alert(xmlHttp.responseText);
  5.     /*var ar=xmlHttp.responseText.split("|");
  6.    al=ar.length;
  7.    document.getElementById("c_cde").value=ar[1] ;
  8.       document.getElementById("tbl1").innerHTML=ar[2] ;*/
  9.    }
  10. }
  11.  
Make sure that is the "alert" getting executed.
Then check, is "innerHTML" is the standard attribute of "document.getElementById("tbl1")".
Let me know these things.
And one more important thing, check the query string what you sending.

Kind regards,
Dmjpro.
Oct 3 '07 #4

100+
P: 110
when i alerted xmlhttprequest thing
it shows <ul><li>india-001</li></ul>
|001|<tr><td>091</td><td>asia</td></tr><tr><td>092</td><td>europe</td></tr>
Oct 3 '07 #5

dmjpro
100+
P: 2,476
when i alerted xmlhttprequest thing
it shows <ul><li>india-001</li></ul>
|001|<tr><td>091</td><td>asia</td></tr><tr><td>092</td><td>europe</td></tr>
That's the problem with "responseText".
Do you know XML.?
Try to use with "responseXML".
And on the client side parse it's each Node with "NodeValue" and create dynamically rows and cells :-)

Any further help please post here.

Kind regards,
Dmjpro.
Oct 3 '07 #6

100+
P: 110
thanks for the reply

as i alerted xmlhttp... countrycodevalue is passed in the text box but only table is not shown although alerted correctly


i dnt know xml
but i instead of creating rows in server.php using php
i have done following thing
and checked alert with xmlhtt it showing the correctly as u say is it something to do with xml ...since i'm new to xml

in the while loop while loop
Expand|Select|Wrap|Line Numbers
  1.  <script>
  2. var tbl = document.getElementById('tblprice');
  3. var lastRow = tbl.rows.length;
  4.  var iteration = lastRow;
  5.   var row = tbl.insertRow(lastRow);
  6.  var cellLeft = row.insertCell(0);
  7.   var textNode = document.createTextNode('<?=$misdcode?>');
  8.   cellLeft.appendChild(textNode);
  9.  
  10.   var cellLeft = row.insertCell(1);
  11.   var textNode1 = document.createTextNode('<?=$mcontinent?>');
  12.   cellLeft.appendChild(textNode1);
  13.   </script>
Oct 3 '07 #7

dmjpro
100+
P: 2,476
thanks for the reply

as i alerted xmlhttp... countrycodevalue is passed in the text box but only table is not shown although alerted correctly


i dnt know xml
but i instead of creating rows in server.php using php
i have done following thing
and checked alert with xmlhtt it showing the correctly as u say is it something to do with xml ...since i'm new to xml

in the while loop while loop
Expand|Select|Wrap|Line Numbers
  1.  <script>
  2. var tbl = document.getElementById('tblprice');
  3. var lastRow = tbl.rows.length;
  4.  var iteration = lastRow;
  5.   var row = tbl.insertRow(lastRow);
  6.  var cellLeft = row.insertCell(0);
  7.   var textNode = document.createTextNode('<?=$misdcode?>');
  8.   cellLeft.appendChild(textNode);
  9.  
  10.   var cellLeft = row.insertCell(1);
  11.   var textNode1 = document.createTextNode('<?=$mcontinent?>');
  12.   cellLeft.appendChild(textNode1);
  13.   </script>
Ok!
Then try with this.

Expand|Select|Wrap|Line Numbers
  1. <tbody><tr><td>091</td><td>asia</td></tr><tr><td>092</td><td>europe</td></tr></tbody>
  2.  
Just update your server.php so that "ar[2]" returns that string.
You got me :-)

Kind regards,
Dmjpro.
Oct 3 '07 #8

100+
P: 110
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. //out of the while loop
  3. var tbl = document.getElementById('tblcountry');
  4. var tbody = tbl.appendChild(document.createElement('tbody'));
  5. var lastRow = tbl.rows.length;
  6. </script>
is the right way to create tbody and then append to table
then how do i append the rows created to this body?
and when i alert
this in the while loop

Expand|Select|Wrap|Line Numbers
  1.  var iteration = lastRow;
  2.   var row = tbody.insertRow(lastRow);
  3.  var cellLeft = row.insertCell(0);
  4.   var textNode = document.createTextNode('<?=$misdcode?>');
  5.   cellLeft.appendChild(textNode);
  6.  
  7.   var cellLeft = row.insertCell(1);
  8.   var textNode1 = document.createTextNode('<?=$mcontinent?>');
  9.   cellLeft.appendChild(textNode1);
  10.   </script>
and if alert ar[2] then i get soemthing like this

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. //out of the while loop
  3. var tbl = document.getElementById('tblcountry');
  4. var tbody = tbl.appendChild(document.createElement('tbody'));
  5. var lastRow = tbl.rows.length;
  6. </script>
  7.  
  8. <script>
  9.   var row = tbody.insertRow(lastRow);
  10.  var cellLeft = row.insertCell(0);
  11.   var textNode = document.createTextNode('091');
  12.   cellLeft.appendChild(textNode);
  13.  
  14.   var cellLeft = row.insertCell(1);
  15.   var textNode1 = document.createTextNode('asia');
  16.   cellLeft.appendChild(textNode1);
  17.   </script>
  18. <script>
  19.  
  20.   var row = tbody.insertRow(lastRow);
  21.  var cellLeft = row.insertCell(0);
  22.   var textNode = document.createTextNode('092');
  23.   cellLeft.appendChild(textNode);
  24.  
  25.   var cellLeft = row.insertCell(1);
  26.   var textNode1 = document.createTextNode('europe');
  27.   cellLeft.appendChild(textNode1);
  28.   </script>
Oct 3 '07 #9

dmjpro
100+
P: 2,476
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. //out of the while loop
  3. var tbl = document.getElementById('tblcountry');
  4. var tbody = tbl.appendChild(document.createElement('tbody'));
  5. var lastRow = tbl.rows.length;
  6. </script>
is the right way to create tbody and then append to table
then how do i append the rows created to this body?
and when i alert
this in the while loop

Expand|Select|Wrap|Line Numbers
  1.  var iteration = lastRow;
  2.   var row = tbody.insertRow(lastRow);
  3.  var cellLeft = row.insertCell(0);
  4.   var textNode = document.createTextNode('<?=$misdcode?>');
  5.   cellLeft.appendChild(textNode);
  6.  
  7.   var cellLeft = row.insertCell(1);
  8.   var textNode1 = document.createTextNode('<?=$mcontinent?>');
  9.   cellLeft.appendChild(textNode1);
  10.   </script>
and if alert ar[2] then i get soemthing like this

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. //out of the while loop
  3. var tbl = document.getElementById('tblcountry');
  4. var tbody = tbl.appendChild(document.createElement('tbody'));
  5. var lastRow = tbl.rows.length;
  6. </script>
  7.  
  8. <script>
  9.   var row = tbody.insertRow(lastRow);
  10.  var cellLeft = row.insertCell(0);
  11.   var textNode = document.createTextNode('091');
  12.   cellLeft.appendChild(textNode);
  13.  
  14.   var cellLeft = row.insertCell(1);
  15.   var textNode1 = document.createTextNode('asia');
  16.   cellLeft.appendChild(textNode1);
  17.   </script>
  18. <script>
  19.  
  20.   var row = tbody.insertRow(lastRow);
  21.  var cellLeft = row.insertCell(0);
  22.   var textNode = document.createTextNode('092');
  23.   cellLeft.appendChild(textNode);
  24.  
  25.   var cellLeft = row.insertCell(1);
  26.   var textNode1 = document.createTextNode('europe');
  27.   cellLeft.appendChild(textNode1);
  28.   </script>

You need not to change your JavaScript Code.
Only .php file.

Kind regards,
Dmjpro.
Oct 3 '07 #10

100+
P: 110
but this code is from server.php
and not a javascript file
here insetad of using php for rows creation in the loop
i have used javascript and dom
to create rows with values
....

tell me if i'm going wrong anywhere


but i'm still confuesd that after choosing country name and country code is shown in the corresponding text box on the main php form then why can't i use it to query a database there in that program itslef rather then going to server.php
and creating rows
i tried to alert in the main program country code it shows it is empty but then it is hwon int he form .....getting totally confused
Oct 3 '07 #11

dmjpro
100+
P: 2,476
but this code is from server.php
and not a javascript file
here insetad of using php for rows creation in the loop
i have used javascript and dom
to create rows with values
....

tell me if i'm going wrong anywhere


but i'm still confuesd that after choosing country name and country code is shown in the corresponding text box on the main php form then why can't i use it to query a database there in that program itslef rather then going to server.php
and creating rows
i tried to alert in the main program country code it shows it is empty but then it is hwon int he form .....getting totally confused

I am also getting confused.
Look :-)
Your alert now shows
Expand|Select|Wrap|Line Numbers
  1. <ul><li>india-001</li></ul>
  2. |001|<tr><td>091</td><td>asia</td></tr><tr><td>092</td><td>europe</td></tr>
  3.  
Now change the server.php file in such a way so that your alert shows ....

Expand|Select|Wrap|Line Numbers
  1. <ul><li>india-001</li></ul>
  2. |001|<tbody><tr><td>091</td><td>asia</td></tr><tr><td>092</td><td>europe</td></tr></tbody>
  3.  
Ok!
Got me.
And no need to change your JavaScript.
What you had before keep it unchanged.

Kind regards,
Dmjpro.
Oct 3 '07 #12

100+
P: 110
i'm getting this alert i just put body tag
Expand|Select|Wrap|Line Numbers
  1. <ul><li>india-001</li></ul>
  2. |001|<tbody><tr><td>091</td><td>asia</td></tr><tr><td>092</td><td>europe</td></tr></tbody>
  3.  

but still the table is not shown int he main form
Oct 3 '07 #13

100+
P: 110
Expand|Select|Wrap|Line Numbers
  1. <form method="get">
  2. <table id="tbl">
  3. <tr>
  4.     <td bordercolor="#669999"> 
  5.         <label><strong><font size="3">Select country</strong></label></td>
  6.       <td colspan="11" bordercolor="#669999"> 
  7.  <input type="text" c_name="c_name" id="c_name" size="40" class="dlight"  autocomplete="off"  onblur="showCode(this.value);">
  8.     <div id="hint"></div>
  9.     <script type="text/javascript"> 
  10.         new Ajax.Autocompleter("c_name","hint","server.php");
  11.     </script>
  12. <input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" > 
  13.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • this c_cde is shown when i select country name correctly
  • depending on this valu i want to fetch records from database and display here and after that show one row to take some new entry form the user i tried even alerting $p_cde but shows blank alert thats y i took that sever.php rows creation
  •  
  •  
  •     
  •  
  • <div id="tbl1">existingrecords from table </div> 
  • //new row to take entry from user 
  • <tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
  • <td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
  • </table>
  • </form>
  • Oct 3 '07 #14

    100+
    P: 110
    thanks
    hey i dnt know how i missed but the data from tables is shown at the top of my table in one line


    how i inset it as a first row my table below the existing header

    Expand|Select|Wrap|Line Numbers
    1. <form method="get">
    2. <table id="tbl">
    3. <tr>
    4.     <td bordercolor="#669999"> 
    5.         <label><strong><font size="3">Select country</strong></label></td>
    6.       <td colspan="11" bordercolor="#669999"> 
    7.  <input type="text" c_name="c_name" id="c_name" size="40" class="dlight"  autocomplete="off"  onblur="showCode(this.value);">
    8.     <div id="hint"></div>
    9.     <script type="text/javascript"> 
    10.         new Ajax.Autocompleter("c_name","hint","server.php");
    11.     </script>
    12. <input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" > 
    [code=text]this c_cde is shown when i select country name correctly
    depending on this valu i want to fetch records from database and display here and after that show one row to take some new entry form the user i tried even alerting $p_cde but shows blank alert thats y i took that sever.php rows creation
    Oct 3 '07 #15

    dmjpro
    100+
    P: 2,476
    thanks
    hey i dnt know how i missed but the data from tables is shown at the top of my table in one line


    how i inset it as a first row my table below the existing header

    Expand|Select|Wrap|Line Numbers
    1. <form method="get">
    2. <table id="tbl">
    3. <tr>
    4.     <td bordercolor="#669999"> 
    5.         <label><strong><font size="3">Select country</strong></label></td>
    6.       <td colspan="11" bordercolor="#669999"> 
    7.  <input type="text" c_name="c_name" id="c_name" size="40" class="dlight"  autocomplete="off"  onblur="showCode(this.value);">
    8.     <div id="hint"></div>
    9.     <script type="text/javascript"> 
    10.         new Ajax.Autocompleter("c_name","hint","server.php");
    11.     </script>
    12. <input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" > 
    [code=text]this c_cde is shown when i select country name correctly
    depending on this valu i want to fetch records from database and display here and after that show one row to take some new entry form the user i tried even alerting $p_cde but shows blank alert thats y i took that sever.php rows creation

    Oh no ............... !!!!!!!!!!!!
    I thought that your tabl1 is an id of Table.
    But it is your Div.
    oh...........!
    So update .php as <table>...</table>
    Now see the results...

    Kind regards,
    Dmjpro.
    Oct 3 '07 #16

    100+
    P: 110
    sorry i didnt get you
    Expand|Select|Wrap|Line Numbers
    1. <form method="get">
    2. <table id="tbl">
    3. <tr>
    4.     <td bordercolor="#669999"> 
    5.         <label><strong><font size="3">Select country</strong></label></td>
    6.       <td colspan="11" bordercolor="#669999"> 
    7.  <input type="text" c_name="c_name" id="c_name" size="40" class="dlight"  autocomplete="off"  onblur="showCode(this.value);">
    8.     <div id="hint"></div>
    9.     <script type="text/javascript"> 
    10.         new Ajax.Autocompleter("c_name","hint","server.php");
    11.     </script>
    12. <input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" >
    13. <div id="tbl1"></div>  //this is where i'm displaying my exsitinnd rows 
    14. <tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
    15. <td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
    16. </table>
    17. </form>
    now wot changes i do to get those rows atthe right place

    thanks
    Oct 3 '07 #17

    dmjpro
    100+
    P: 2,476
    Oh!
    Right now I understood what to do next.
    :-)

    Expand|Select|Wrap|Line Numbers
    1. <div><table><tbody id="tbl1">
    2. <tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
    3. <td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
    4. </tbody></table>
    5. </div>
    6.  
    Have a creafull look at this code what i changed in your main php file.

    And what your first server php was, change it to that.
    I mean your tag starts with <tr>...</tr>
    And change the JavaScript ....
    Expand|Select|Wrap|Line Numbers
    1. document.getEocumentById('tabl1').innerHTML=document.getEocumentById('tabl1').innerHTML+xmlHttp.responseText;
    2.  
    Try this.

    Kind regards,
    Dmjpro.
    Oct 3 '07 #18

    100+
    P: 110
    thnks
    i made below changes and thnak you once again it works
    but partially
    not exactly wot i want
    it dispalys the records below the header of my table but it blanks my text box values for country name and country code
    i think something related to this statement
    document.getElementById('tbl1').innerHTML=document .getElementById('tbl1').innerHTML+xmlHttp.response Text;


    it overwites my existing rows from the html table from main program or is it because i'm using one more div =hint which is used for autocomplete
    Oct 3 '07 #19

    dmjpro
    100+
    P: 2,476
    Ok!
    I changed your whole code of server.php.

    Expand|Select|Wrap|Line Numbers
    1. <?php
    2. include("../include/con.php");
    3. $sql = "select c_code,c_name from countrymaster  where c_name like '%" . $_GET['c_name'] . "%'";
    4.     $rs = $DB_site->query($sql);
    5. ?>
    6. <ul>
    7. <? while($data = $DB_site->fetch_array($rs)) { ?>
    8.   <li><? echo stripslashes($data['c_name']."-".$data['c_cde']);
    9.   ?></li>
    10. <? } ?>
    11. </ul> 
    12. <?
    13. if($_GET['c_name']!=""){
    14.     $mc_name=$_GET['c_name'];
    15.     $mc_cde=$_GET['c_cde'];
    16.     echo "|".$mc_cde."|";
    17. }
    18. $sql1="select * from countrydetails where c_cde='".$mc_cde."'";
    19.      $db_query_pricelist=$DB_site->query($sql1);
    20.      while($rs=$DB_site->fetch_array($db_query_rs)){
    21.              $misdcode=$rs[isdcode'];
    22.             $mcontinent=$rs['continent'];
    23.         ?>
    24.                                                <tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode;?>"></td>
    25.                                                         <td><input type="text" name="continent" id="continent" value="<?=$mcontinent;?>"></td>
    26.                                                </tr>
    27.             <?     } ?>
    Now change in JavaScript .......

    Expand|Select|Wrap|Line Numbers
    1. document.getEocumentById('tabl1').innerHTML=docume  nt.getEocumentById('tabl1').innerHTML+ar[2];
    2.  
    Now try this.
    Check the php code becuase i m j2ee man :-)

    Kind regards,
    Dmjpro.
    Oct 3 '07 #20

    100+
    P: 110
    Thanks once againi chaged my server.php and also the
    javascipt code

    Expand|Select|Wrap|Line Numbers
    1. document.getElementById('tbl1').innerHTML=document.getElementById('tbl1').innerHTML+ar[2];

    but still it blank my country code and country name so below this stateme nt i have added statement for again assigning country code and country name which are erased by the above statement


    it works in ozilla but gives me runtime error for the above statement of javascript in internet explorer and doesnt display my fetched records from the database
    Oct 4 '07 #21

    dmjpro
    100+
    P: 2,476
    Thanks once againi chaged my server.php and also the
    javascipt code

    Expand|Select|Wrap|Line Numbers
    1. document.getElementById('tbl1').innerHTML=document.getElementById('tbl1').innerHTML+ar[2];

    but still it blank my country code and country name so below this stateme nt i have added statement for again assigning country code and country name which are erased by the above statement


    it works in ozilla but gives me runtime error for the above statement of javascript in internet explorer and doesnt display my fetched records from the database
    Well forgot to say you to change the main.php also.
    Have a llok at this :-)

    Expand|Select|Wrap|Line Numbers
    1. <form method="get">
    2. <table id="tbl">
    3. <tr>
    4.     <td bordercolor="#669999"> 
    5.         <label><strong><font size="3">Select country</strong></label></td>
    6.       <td colspan="11" bordercolor="#669999"> 
    7.  <input type="text" c_name="c_name" id="c_name" size="40" class="dlight"  autocomplete="off"  onblur="showCode(this.value);">
    8.     <div id="hint"></div>
    9.     <script type="text/javascript">    
    10.         new Ajax.Autocompleter("c_name","hint","server.php");
    11.     </script>
    12. <input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" >
    13. <div><table><tbody id = "tbl1">
    14. <tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
    15. <td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
    16. </tbody></table></div>
    17. </form>
    18.  
    Enjoy this code.
    Good Luck.

    Kind regads,
    Dmjpro.
    Oct 4 '07 #22

    100+
    P: 110
    thanks
    Expand|Select|Wrap|Line Numbers
    1. <form method="get">
    2. <table id="tbl">
    3. <tr>
    4.     <td bordercolor="#669999"> 
    5.         <label><strong><font size="3">Select country</strong></label></td>
    6.       <td colspan="11" bordercolor="#669999"> 
    7.  <input type="text" c_name="c_name" id="c_name" size="40" class="dlight"  autocomplete="off"  onblur="showCode(this.value);">
    8.     <div id="hint"></div>
    9.     <script type="text/javascript">    
    10.         new Ajax.Autocompleter("c_name","hint","server.php");
    11.     </script>
    12. <input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" >
    13. <div><tbody id = "tbl1"> //JUST REMOVED <TABLE> FROM HERE 
    14. <tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
    15. <td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
    16. </tbody></table></div>
    17. </form>
    18.  
    this works on mozilla with following stat document.getElementById("tbl1")+=document.getEleme ntById("tbl1")+ar[2];
    but this statement gives me runtime error with Internet explorer

    this is for my knowledge please excuse if my query sounds absurd
    also one imp thing is that i wanted to know that after selecting from text box the value are shown but when i try to write a query in the main form itself
    where country name and country code are seen i cant query my table depending upon the country code
    my query is not getting the value
    actually earlier i was trying for that i wanted to select from my text box tand then just put the values in country code and country name using server.php and then in the main form itself write a query to get more details from table using countrycode
    Oct 5 '07 #23

    100+
    P: 110
    I'm getting runtime error for internet explorer

    for the below code
    Oct 9 '07 #24

    dmjpro
    100+
    P: 2,476
    I'm getting runtime error for internet explorer

    for the below code
    Happy to see that you found your code worked in Mozilla.
    What error you getting in IE?

    Debasis Jana
    Oct 9 '07 #25

    100+
    P: 110
    Happy to see that you found your code worked in Mozilla.
    What error you getting in IE?

    Debasis Jana

    Expand|Select|Wrap|Line Numbers
    1.  document.getElementById("tbl1")+=document.getElementById("tbl1")+ar[2];
    but this statement gives me runtime error with Internet explorer

    this is for my knowledge please excuse if my query sounds absurd
    also one imp thing is that i wanted to know that after selecting from text box the value are shown but when i try to write a query in the main form itself
    where country name and country code are seen i cant query my table depending upon the country code
    my query is not getting the value
    actually earlier i was trying for that i wanted to select from my text box tand then just put the values in country code and country name using server.php and then in the main form itself write a query to get more details from table using countrycode
    Oct 15 '07 #26

    dmjpro
    100+
    P: 2,476
    Expand|Select|Wrap|Line Numbers
    1.  document.getElementById("tbl1")+=document.getElementById("tbl1")+ar[2];
    but this statement gives me runtime error with Internet explorer

    this is for my knowledge please excuse if my query sounds absurd
    also one imp thing is that i wanted to know that after selecting from text box the value are shown but when i try to write a query in the main form itself
    where country name and country code are seen i cant query my table depending upon the country code
    my query is not getting the value
    actually earlier i was trying for that i wanted to select from my text box tand then just put the values in country code and country name using server.php and then in the main form itself write a query to get more details from table using countrycode
    It should be ...
    Expand|Select|Wrap|Line Numbers
    1. document.getElementById("tbl1").innerHTML +=document.getElementById("tbl1").innerHTML+ar[2]
    2.  
    Debasis Jana
    Oct 15 '07 #27

    100+
    P: 110
    It should be ...
    Expand|Select|Wrap|Line Numbers
    1. document.getElementById("tbl1").innerHTML +=document.getElementById("tbl1").innerHTML+ar[2]
    2.  
    Debasis Jana

    Error: invalid assignment left-hand side

    Expand|Select|Wrap|Line Numbers
    1. document.getElementById("tbl1")+=document.getElementById("tbl1")+ar[2];
    Oct 16 '07 #28

    100+
    P: 110
    Error: invalid assignment left-hand side with internet explorer


    Expand|Select|Wrap|Line Numbers
    1. document.getElementById("tbl1")+=document.getElementById("tbl1")+ar[2];
    Oct 17 '07 #29

    100+
    P: 110
    Error: invalid assignment left-hand side with internet explorer


    Code: ( javascript )
    document.getElementById("tbl1")+=document.getEleme ntById("tbl1")+ar[2];

    it is because of object is created in some different way in IE or something to do with a my cross browser creation function

    Expand|Select|Wrap|Line Numbers
    1. function GetXmlHttpObject1()
    2. {
    3. var xmlHttp=null;
    4. try
    5.  {
    6.  // Firefox, Opera 8.0+, Safari
    7.      xmlHttp=new XMLHttpRequest();
    8.  }
    9. catch (e)
    10.  {
    11.      //Internet Explorer
    12.      try
    13.       {
    14.           xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    15.       }
    16.      catch (e)
    17.       {
    18.  
    19.           xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    20.       }
    21.  }
    22.     if (!xmlHttp && typeof XMLHttpRequest!='undefined') { 
    23.     xmlHttp = new XMLHttpRequest(); 
    24.     }
    25. return xmlHttp;
    26. }
    Oct 18 '07 #30

    acoder
    Expert Mod 15k+
    P: 16,027
    Please use code tags when posting code like this:
    [CODE=javascript]
    Your JavaScript code goes here...
    [/code]
    Oct 18 '07 #31

    Post your reply

    Sign in to post your reply or Sign up for a free account.