Hi every one. I have a problem with combinning two scripts.
Fisrt script is working perfectly and taking stuf from mysql:

    function showUser(str)
        if (str=="")

        if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          if (xmlhttp.readyState==4 && xmlhttp.status==200)


The second one is working perfectly and it's simple script for inserting data after change:

<script type="text/javascript">
        $("#selection").change(function () {
        $("#someDivName").html( $("#selection option:selected").val() );

now the hole point is to combine them.
It's look like, when I load the site it don't have id selection and second script stops but after taking data from php and mysql file test-search.php the missing id selection is on site but the first script is not checking if id selection apear and don't work.

The php code:


$con = mysql_connect('localhost', 'root', '');
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("table", $con);

$sql="SELECT * FROM prod_models WHERE prod_main_group_id = '".$q."'";

$result = mysql_query($sql);

echo '
<select id="selection" name="prod_main_group_id" onchange="change_val()">
<option value="">Wybierz produkt</option>

while($row = mysql_fetch_array($result))
  echo '<option value="'.$row['id'].'">';
  echo $row['product_name'] . "</option>";

echo "</select>



Code to display changed script:

<input type="text" id="someDivName" value="" />

if any one can help with solving the problem will be realy nice.
Thx i'm waiting for it now and trying to solve this for my self but now I don't have other ideas for it.

I have solved my problem.

<select id="selection" name="prod_main_group_id" onchange="$(\'#someDivName\').val($(\'#selection option:selected\').text())">