View Full Version : ajax call is not showing correctly

Sep 20th, 2011, 01:56 PM
i'm doing the following on a select box to load the next select box (in a td with the id)

if I look at the html returned by the ajax call I get

<select name=optionvalue /><option value='test 1'>test 1</option><option value='test 2'>test 2</option><option value='test 3'>test 3</option></select>

but it's showing as

the select box and then

test 1test 2test 3

my javascript code is

function Loadoptionvalueselect() {
urltoajax = "getoptionsvaluesselect.asp?1=1"
strarea = document.getElementById('optionid').value;

urltoajax = urltoajax + '&optionid=' + strarea
urltoajax = urltoajax + '&rnd=' + Math.round(Math.random() * 10000)
// alert(urltoajax);
url: urltoajax,
cache: false,
success: function(html) {


any ideas what could be causing this?

Sep 20th, 2011, 06:11 PM
Yes it's actually quite simple

with /> you are closing the select tag already. Just omit the /

Sep 20th, 2011, 06:12 PM
I don't know if this might have anything to do with it, but it looks like your first <select> is being closed before you get to your options:

<select name=optionvalue /> (prematurely closed?)
<option value='test 1'>test 1</option>
<option value='test 2'>test 2</option>
<option value='test 3'>test 3</option>

Sep 21st, 2011, 08:00 AM
thanks you spotted it - that was the problem