jQuery(function($) {
$.ajax({
url: 'proxy.php?url=http://school.egg-one.com/ws/player/full-profile/player_id/17353',
contentType: "application/json; charset=windows-1252",
dataType: "json",
success: function(content) {
$('#mycontent').html("" + $('#mainbuy').html() + "");
},
/* Error */
error: function(xhr, status, error){
alert("No Json" + xhr.status);
},
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mainbuy" style="display:none;">
<div class="coachbtn"><div class="dropup"><div id="buybtn">
<select class="selectpicker" data-style="btn-primary" id="pickhour" name="pickhour">
<option value="1">1H</option>
<option value="2" selected>2H</option>
<option value="3">3H</option>
<option value="4">4H</option>
</select>
</div></div></div>
<div class="coachbtn2"><div id="buybtn2">
<a id="egglink" class="button button-large" style="width: 260px">Reserver</a>
</div></div>
<script type="text/javascript">
$(document).ready(function(){
$('#pickhour').change(function(){
pickhour1 = $(this).val();
$("#egglink").attr("href", "http://school.egg-one.com/private-lesson/program-choice/program_choice/" + pickhour1 + "/player_id/457857");
});
});
</script>
</div>
<a href="#mycontent"></a>
The HTML part define a select dropbox and a button, they got ID "pickhour" for the select and "egglink" for the button. My script in the parent div of all of these divs (im trying some tricks with css.. i dont think my problem is about that) should add the select option value to my link then set it as HREF for my button. Since I call the div "mainbuy" (which contain selectbox + button + script) in an Ajax request (you can see $('#mainbuy').html()), the content is show but the script has absolutely no effect.. I really hope someone will have a way to fix that, or a working alternative..
Thanks you in advance for answers