PDA

View Full Version : Resolved .text() output



ggalan
06-16-2011, 02:59 PM
i have a list output with unique names all under a.name
i would like to capture its unique text value, how would i write this?



<html>
<head>
<script>
$(document).ready(function() {

$("#output a").click(function () {
var name = $(".name").text();// outputs the first entry 'sample keyword 633379194 0'
var prodid = $("#prodid").val();
$.post("class/i.Name.php", { name: name, prodid: prodid },
function(data){
$("#listColumn").html(data);
});
});
</script>

<title></title>


</head>
<body>
<div id="output">
<ul>
<li><a class="name" type="text" name="sample keyword 633379194 0">sample keyword 633379194 0</a></li>
<li><a class="name" type="text" name="Red Herring 1">Red Herring 1</a></li>
<li><a class="name" type="text" name="sample keyword 633379194 2">sample keyword 633379194 2</a></li>
<li><a class="name" type="text" name="Red Herring 3">Red Herring 3</a></li>
<li><a class="name" type="text" name="sample keyword 633379194 4">sample keyword 633379194 4</a></li>
</ul>
</div>

<input name="prodid" id="prodid" type="hidden" value="<?php echo $prodid;?>" />

</body>
</html>



heres the class i.Name


<?
include_once('class.name.php');
include_once('class.db.php');

$name = $_POST['name'];
$prodid = $_POST['prodid'];



if ( $name == true) {
$insertDB = new db;
$insertDB->insertSQL = "INSERT INTO research VALUES ('$prodid', '$name')";
$insertDB->insert();
}

?>

heres the dB result, i want unique entries
http://www.2020proj.com/media/images/computer/dbResult.JPG

ggalan
06-16-2011, 05:13 PM
over looked the obvious replaced with this


var name = $(this).text();
//var name = $("#name").text();