JQuery and PHP display problem

Posted by TheCREATOR on Stack Overflow See other posts from Stack Overflow or by TheCREATOR
Published on 2010-04-20T05:34:14Z Indexed on 2010/04/20 5:43 UTC
Read the original article Hit count: 390

Filed under:
|

I'm new to JQuery but for some reason I cant get the php code to display correctly when I put it in my JQuery script. The php code will display correctly when its not in the JQuery code can someone help me fix my JQuery code so it will display my PHP code correctly?

Here is the JQuery and PHP code.

var count = 0;
$(function(){
    $('p#add_field').click(function(){
        count += 1;
        $('#container').append(
            '<input type="text" name="sk" id="sk" />'
            + '<label for="exp">Exp: </label>'
            + '<?php'
            + 'echo \'<select id="exp" name="exp">\' . "\n";'
              + 'foreach($options as $option) {'
                + 'if ($option == $exp) {'
                  + 'echo \'<option value="\' . stripslashes(htmlentities(strip_tags($option))) . \'" selected="selected">\' .' 
                  + ' stripslashes(htmlentities(strip_tags($option))) . \'</option>\' . "\n";'
                + '} else {'
                  + 'echo \'<option value="\'. stripslashes(htmlentities(strip_tags($option))) . \'">\' .' 
                  + 'stripslashes(htmlentities(strip_tags($option))) . \'</option>\'."\n";'
                + '}'
              + '}'
            + 'echo \'</select>\';'
            + '?>'
            + '<label for="g">RGB: </label>'
            + '<?php'
            + 'echo \'<select id="g" name="g">\' . "\n";'
              + 'foreach($options as $option) {'
                + 'if ($option == $g) {'
                  + 'echo \'<option value="\' . stripslashes(htmlentities(strip_tags($option))) . \'" selected="selected">\' .' 
                  + 'stripslashes(htmlentities(strip_tags($option))) . \'</option>\' . "\n";'
                + '} else {'
                  + 'echo \'<option value="\'. stripslashes(htmlentities(strip_tags($option))) . \'">\' .' 
                  + 'stripslashes(htmlentities(strip_tags($option))) . \'</option>\'."\n";'
                + '}'
              + '}'
            + 'echo \'</select>\';'
            + '?></li>' );

    });
});

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery