.()HTML not working!!!!
.()HTML not working!!!!
Hi,
Im trying to use .html() to output span and input data which is used for a button to add an item to a cart with Smart Cart.
http://plugins.jquery.com/project/smartcart
I have tried with the code below but its not working, the ouput seems correct but its just not triggering the button to add the item to the cart!
- <div class="scProductListItem">
<span>Choose Item</span>
<select name="select1" id="select1" size="1">
<option value="item_1">Item 1</option>
<option value="item_2">Item 2</option>
</select>
<script>
$(document).ready(function(){
$("#divselect1").html(
'<span class="hide" id="prod_name' +$('#select1').val()+ '">Item Name</span>' + '<br />' +
'<span class="hide" id="prod_price' +$('#select1').val()+ '"></span>' + '<br />' +
'<input type="hidden" name="prod_qty" class="scText" id="prod_qty' +$('#select1').val()+ '" value="1" />' + '<br />' +
'<input type="button" rel="' +$('#select1').val()+ '" class="scItemButton scBtn" value="Add Product" />'
)
});</script>
<div id="divselect1">test</div>
</div>
It needs to output as follows. (select_value) = the chosen option from the dropdown select!
- <span>Choose Item</span>
<select name="select1" id="select1" size="1">
<option value="item_1">Item 1</option>
<option value="item_2">Item 2</option>
</select>
<span class="hide" id="prod_name(select_value)">Item Name</span><br />
<span class="hide" id="prod_price(select_value)"></span></br />
<input type="hidden" name="prod_qty" class="scText" id="prod_qty(select_value)" value="1" /><br />
<input type="button" rel="(select_value)" class="scItemButton scBtn" value="Add Product" />
Any help would be much appreciated!
Many thanks!