0

I have a upload image script and now I want update uploaded images in my database. I have used a php foreach loop and radio input for show each image and select which image is updated now my problem it's: when I select a radio bottom only send a random value with jquery to my php file but I want send only my selected radio value to my php file. My php loop is:

<?php foreach($images as $image) { ?>

<?php $src = JURI::base().'images/discount/'.$image['name']; ?>
<input type="radio" name="imgname" id="imgname" value="<?php echo $image['name'] ?>"><img src="<?php echo $src ?>" alt="" height="100" width="100" />

 <?php } ?> 

And this part of my jquery send radio value to my php file:

vpb_data.append('imgpath', $('#imgpath').val());
1

2 Answers 2

2

Try this -

$(function(){
   $("#imgpath").on('click',function(){
       var value = $(this).val();
       vpb_data.append('imgpath', value);
   });
});
Sign up to request clarification or add additional context in comments.

Comments

0

I found how can do it I change my jquery to this and it's work:

vpb_data.append('imgname', $('input:radio[name=imgname]:checked').val());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.