Results 1 to 2 of 2

Thread: .text() output

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default .text() output

    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?

    Code:
    <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
    Code:
    <?
    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
    Last edited by ggalan; 06-16-2011 at 05:13 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    over looked the obvious replaced with this
    Code:
    var name = $(this).text();
    //var name = $("#name").text();

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •