i have added html elements at run time using append Code:
function addFormField() {
$("#inputss").append("<strong>asif</strong>"); }
but how can i add a select element at run time that looks like this..
PHP Code:
<select name="pre_req" id="pre_req" class="inputs"
value=<? if($this->uri->segment(2)=='update') echo $results['pre_req']?>>
<option value='None'>None</option> 开发者_JS百科
<? foreach($combo1 as $row)
echo "<option value=$row[sub_name]>$row[sub_name</option>";
?>
</select>
If you want to have client-side (ie. JavaScript code) that adds an HTML element you obviously cannot have PHP code there. You would need to have a web page written in PHP that returns the HTML you want for the element you want and then insert that element using jQuery. jQuery has a really handy method for this $.load(), but you need to create an element first. Eg.
$("#inputss").append("<div id='placeholder'></div>");
$("#placeholder").load('someAjaxService.php')
精彩评论