Previously I asked about how I could call separate values from a text file without using php ( Include .txt content WITHOUT server side lang? ), and with some of your help I solved the problem:
<script type="text/javascript">
jQuery.get('db.txt', function(data) {
$('#db').html(data);
var element = $("#db").text().split("|");
$('#1').text(element[1]);
$('#3').text(element[3]);
});
</script>
<span id="db" style="display:none;"></span>
<span id="1"></span>
<span id="3"></span>
If my text file looks like this Name1 | Number1 | Name2 | Number2 | it will display:
Number 1 Number 2
Works great, except I have ONE little problem left.
Before, when I used php, I had an OnClick function that looked like this:
onClick="simpleCart.add('name=Productname', 'price=<?php echo ''.$field[$loop][1].''; ?>','quantity=1');
The price was echoed from the database with php, but now I can't use any server side language any more. <span id="1"></span>
gets the same value as <?php echo ''.$field[$loop][1].''; ?>
does, I just don't know how to write it in the OnClick function? I need the span value to be equal the price.
Hope you can help me out here!