양식의 필드를 복제하는 방법에 관한이 코드를 가지고 있습니다. 이제는이 양식이 텍스트 필드이지만 웹 사이트의 모든 페이지가있는 드롭 다운 목록을 갖고 싶습니다.PHP 값을 사용하여 JQuery에서 드롭 다운을 작성하십시오.
내가 jQuery를
을 작성하는 방법을 알고하지 않기 때문에 그것은 단지 PHP에 있다면 이것은 쉬운 것입니다 그래서 친절하게도 나를 위해이 두 가지 코드를 결합 할 의사가 거기에 사람이있다 :
JQuery와 :
<select name="meta-url-1" id="meta-url-1"><?php
global $post;
$args = array('numberposts' => -1);
$posts = get_pages($args);
echo '<option value="#"></option>';
foreach($posts as $post) : setup_postdata($post); ?>
<option value="<?php echo $post->post_name; ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
</select>
Notic이 PHP와
<script type="text/javascript">
var fieldname = <?php echo json_encode($this->get_field_name('stream_sources')) ?>;
var fieldnum = <?php echo json_encode($stream_counter-1) ?>;
jQuery(function($) {
var count = fieldnum;
$('.<?php echo $this->get_field_id('add_field');?>').click(function() {
$("#<?php echo $this->get_field_id('field_clone');?>").append("<p><input type='text' name='"+fieldname+"["+(count+1)+"][title] value='' class='widefat sourc"+(count+1)+"'><span class='remove-field button button-primary button-large'>Verwijderen</span></p>");
count++;
});
$(".remove-field").live('click', function() {
$(this).parent().remove();
});
});
</script>
e PHP는 필자가 작성하는 방법입니다. 그러나 반복 할 수있는 분야에서 드롭 다운을해야합니다.
희망이 있습니다. & & 누구든지 도움이 될 것입니다. M.
입니까? –
@rack_nilesh 무엇? 회신을 위해 – Interactive