Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  134] [ 7]  / answers: 1 / hits: 74732  / 10 Years ago, thu, april 3, 2014, 12:00:00

I'm a newbie to Javascript so I couldn't find an answer to my problem. I want to add an extra select when a previous select is changed. I know my code should look something likes this but it isn't working:



$(function(){
$('#artist').change(function(){
$.ajax({
url: artist_field.php,
dataType:html,
type: post,
success: function(data){
$('#artist').append(data);
}
});
});
});


HTML



<td id=artist>
<select name=artist_1 id=artist>
<option value=></option>
</select>
</td>


My problem is that I don't know how to get the values in artist_field.php that I'm trying to send (because I'm trying to exclude the previous selected option in the new select). I hope someone can help me! Thanks in advance.


More From » php

 Answers
19
$(document).ready(function() {
$('#select_2').hide();
$('#artist').change(function(){
$('#select_2').show();
});
});


HTML



<td id=artist>
<select name=artist_1 id=artist>
<option value=></option>
</select>
</td>
<td>
<select name=select_2 id=select_2>
<option value=></option>
</select>
</td>


It will only show the second select if you chose something on the first one


[#71640] Wednesday, April 2, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
analiseb

Total Points: 252
Total Questions: 96
Total Answers: 106

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
analiseb questions
;