Jump to content

Help needed


esack

Recommended Posts

I have a javascript/AJAX code that gets 3 drop down lists from a script on the server and displays them in the web page. If a selection is made the AJAX will populate again using the variables selected in the lists. I am having problems getting the selected value from the lists. Any help would be great. If it helps you can see the main parts of the code.

 

Client:

 

function getLabels(myfrom, first)

{

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

{

alert ("Browser does not support HTTP Request")

return

}

var lb1="";

var lb2="";

var lb3="";

 

lb1=myfrom.label1.selectedValue;  //this does not work it gives undefined

 

var url="matrix_details.php?id=<?php echo $colname__myProduct;?>&label1=" + lb1;

 

xmlHttp.onreadystatechange=stateChanged

xmlHttp.open("GET",url,true)

xmlHttp.send(null)

}

 

HTML:

 

    <td id="labelOptions">

    hi

    </td>

 

 

function stateChanged()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

{

document.getElementById("labelOptions").innerHTML = xmlHttp.responseText;

}

}

 

Server: PHP

 

echo '<tr>';

echo ' <td align="right">'. $matrix->Fields('label1').'</td>';

echo ' <td>';

echo ' <select onchange="popLabels(document.myform)" name="label1" >';

echo '   <option value="">Select</option>';

 

while(!$matrix_products->EOF)

{

if(checkLabel($labelDes,$matrix_products->Fields($label)))

{

echo '    <option ';

if($matrix_products->Fields($label) == $labels[$i-1])

echo 'selected="selected" ';

 

echo 'value="'.$matrix_products->Fields($label).'">'.$matrix_products->Fields($label);

 

if($i == $priceLabel)

echo ' - '.$matrix_products->Fields('price');

 

echo '</option>';

 

$labelDes[]=$matrix_products->Fields($label);

}

 

$matrix_products->MoveNext();

}

echo ' </select></td></tr>';

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.