Welcome Guest, Not a member yet? Register   Sign In
need help getting hidden input dynamic value
#1

[eluser]doforumda[/eluser]
Hi all,

I am making a t shirt website. I have about eight t-shirt thumbnails and these thumbnails are inside div tag with class 'thumbs'. Inside this thumbs div I have hidden input field as well. The value of thumbs div is the ID of the current thumbnail which taken from mysql database. Now what am I trying to do is when user clicks thumbs div tag then in javascript it should alert me the value of hidden input of this clicked thumbs div tag. Currently it displays only the first thumbnails hidden input value i.e. 1.

SO How can I make this work so that when user clicks thumbs div tag, the value of that clicked thumbs' hidden input must be alerted?

here is my code so far

here is thumbs page
Code:
<!DOCTYPE HTML>
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
[removed][removed]
[removed][removed]
&lt;link type="text/css" rel="stylesheet" href="styles/styles.css" /&gt;
&lt;title&gt;title&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<div id="left_menu">
    <div id="tshirt_thumbs_container">
        &lt;?php if($rows) : ?&gt;
        &lt;?php foreach($rows as $r) : ?&gt;
        &lt;?php echo ""; ?&gt;
        &lt;?php echo "<div class='thumbs'>"; ?&gt;
        &lt;?php echo "<img >shirt_thumburl . "' />"; ?&gt;
        &lt;?php echo "&lt;input type='hidden' id='thumbid' value='" . $r-&gt;shirtid . "' />"; ?&gt;
        &lt;?php echo "</div>"; ?&gt; &lt;!-- thumbs --&gt;
        &lt;?php endforeach; ?&gt;
        &lt;?php endif; ?&gt;
    </div>
</div>&lt;!-- left_menu --&gt;
<div id="contents"></div>
&lt;/body&gt;
&lt;/html&gt;

here is .js file
Code:
$(function(){
    $('.thumbs').click(function() {
        var thisid = $(this + 'input[type="hidden"]').val();
        //var thisid = $(this + " #thumbid").attr('id');
        alert(thisid);
    })
});
please help




Theme © iAndrew 2016 - Forum software by © MyBB