iframe内でselectを使用した際のリンク先を親フレームで切り替えたいのですがうまくできません。
ご教授お願い致します。
html
1<div> 2<iframe src="./iframe.html" frameborder="0" scrolling="no" align="center"></iframe> 3</div>
iframe.html
html
1<div> 2<select class="parent" name="foo"> 3 <option value="" selected="selected">種類1</option> 4 <option value="1">1</option> 5 <option value="2">2</option> 6 <option value="3">3</option> 7</select> 8 9<select class="children" name="select" disabled> 10 <option value="" selected="selected">種類2</option> 11 <option value="1" data-val="1">1</option> 12 <option value="2" data-val="2">2</option> 13 <option value="3" data-val="3">3</option> 14</select> 15 16<select class="children02" name="bar" disabled onchange="blur(); location.href = this.value;"> 17 <option value="" selected="selected">種類3</option> 18 <option value="http://1.html" data-val="1">1</option> 19 <option value="http://2.html" data-val="2">2</option> 20 <option value="http://3.html" data-val="3">3</option> 21</select> 22</div>
javascript
1$(function() { 2var $children = $('.children'); 3var original = $children.html(); 4 5$('.parent').change(function() { 6 7 var val1 = $(this).val(); 8 9 $children.html(original).find('option').each(function() { 10 var val2 = $(this).data('val'); 11 12 if (val1 != val2) { 13 $(this).not(':first-child').remove(); 14 } 15 16 }); 17 18 if ($(this).val() == "") { 19 $children.attr('disabled', 'disabled'); 20 } else { 21 $children.removeAttr('disabled'); 22 } 23 24}); 25 26}); 27 28$(function() { 29var $children = $('.children02'); 30var original = $children.html(); 31 32$('.children').change(function() { 33 34 var val1 = $(this).val(); 35 36 $children.html(original).find('option').each(function() { 37 var val2 = $(this).data('val'); 38 39 if (val1 != val2) { 40 $(this).not(':first-child').remove(); 41 } 42 43 }); 44 45 if ($(this).val() == "") { 46 $children.attr('disabled', 'disabled'); 47 } else { 48 $children.removeAttr('disabled'); 49 } 50 51}); 52 53});
ご教授お願い致します。
回答1件
あなたの回答
tips
プレビュー