Find the value of input type text closest to checkbox using jquery
<p><a href="http://jsfiddle.net/pVA36/" rel="nofollow">Working code in JSFIDDLE</a></p>

<p>I have put the complete code in JSFiddle, the problem is that it fetches the val of the first input box,but doesn't fetch the content where the checkbox is checked? </p>

<p>Html</p>

<pre><code>&lt;div class="gallery_content_wrap"&gt;
&lt;!-- video wrap--&gt;

&lt;div class="gallery_photo_wrap"&gt;
  &lt;div class="gallery_bg_wrap"&gt;
  &lt;input type="hidden" value="10" name="selectypeaccept"&gt;
  &lt;input type="hidden" value="photos" name="subadmintypeaccept"&gt;

        &lt;div name="photosacceptdiv" class="gallery_bg"&gt; &lt;img width="200px" border="0" height="148px" src="http://farm8.staticflickr.com/7180/6846918679_7891edd209_t.jpg"&gt;  
&lt;br&gt;   &lt;input type="text" value="" id="phototitle"&gt;  &lt;input type="checkbox" value="1d7457596c0f202ae373de1737bb0e4a.png" name="photosaccept"&gt;
      &lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- video wrap--&gt;



&lt;div class="gallery_photo_wrap"&gt;
  &lt;div class="gallery_bg_wrap"&gt;
  &lt;input type="hidden" value="10" name="selectypeaccept"&gt;
  &lt;input type="hidden" value="photos" name="subadmintypeaccept"&gt;

        &lt;div name="photosacceptdiv" class="gallery_bg"&gt; &lt;img width="200px" border="0" height="148px" src="http://farm7.staticflickr.com/6186/6054843777_4e90c30827_t.jpg"&gt;  
&lt;br&gt;   &lt;input type="text" value="" id="phototitle"&gt;  &lt;input type="checkbox" value="3.png" name="photosaccept"&gt;
      &lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- video wrap--&gt;



&lt;div class="gallery_photo_wrap"&gt;
  &lt;div class="gallery_bg_wrap"&gt;
  &lt;input type="hidden" value="10" name="selectypeaccept"&gt;
  &lt;input type="hidden" value="photos" name="subadmintypeaccept"&gt;

        &lt;div name="photosacceptdiv" class="gallery_bg"&gt; &lt;img width="200px" border="0" height="148px" src="http://farm8.staticflickr.com/7021/6846957961_779518a6c5_t.jpg"&gt;  
&lt;br&gt;   &lt;input type="text" value="" id="phototitle"&gt;  &lt;input type="checkbox" value="9d0757dd339b0b1afa3aabe6b1a50cda.png" name="photosaccept"&gt;
      &lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- video wrap--&gt;



&lt;div class="gallery_photo_wrap"&gt;
  &lt;div class="gallery_bg_wrap"&gt;
  &lt;input type="hidden" value="10" name="selectypeaccept"&gt;
  &lt;input type="hidden" value="photos" name="subadmintypeaccept"&gt;

        &lt;div name="photosacceptdiv" class="gallery_bg"&gt; &lt;img width="200px" border="0" height="148px" src="http://farm8.staticflickr.com/7181/6858152461_91dd47bfc8_t.jpg"&gt;  
&lt;br&gt;   &lt;input type="text" value="" id="phototitle"&gt;  &lt;input type="checkbox" value="26a70bb20de5d595d2fde46abbc740f8.png" name="photosaccept"&gt;
      &lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- video wrap--&gt;




&lt;/div&gt;&lt;div align="center"&gt;&lt;input type="submit" name="submitaccept" value="Approve"/&gt;&lt;input type="submit" name="submitacceptreload" value="Reload"/&gt;
&lt;/div&gt;
</code></pre>

<p>​
Jquery</p>

<pre><code> $("[name=submitaccept]").click(function(){
          checktype();
 });

 function checktype(){

            $("[name=photosaccept]").each(function() {

                 if ($(this).is(':checked')) {
                     $phototitle=$(this).val();
                     alert($("#phototitle").val());
                        $photoname = $("#phototitle").val();
                 }
                 });

                 }​
</code></pre>
