Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8197029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:39:19+00:00 2026-06-07T05:39:19+00:00

I have this jQuery code, when i click the first value of the Select

  • 0

I have this jQuery code, when i click the first value of the Select it insert to the database, But when i click the second value of the Select, it insert again THE FIRST value of the Select. How can i insert the 2nd value of the select.
the sample link is : http://cocopop12.site11.com/search/index.php

the jQuery code of mine is :

$(function() {
    $(".videoThumbS").click(function() {
        var dataString = $("#v_w_id_value").val();
        $.ajax({ 
            type: 'POST',                                  
            url: 'api.php',
            data: { v_w_id: dataString },
            dataType: 'html',               
            success: function(data)  
            {
            var v_w_id_value = data[0];           //get name
            $('#selected_thumbs').html("yt id:" + v_w_id_value );     //Set output element html
            } 
        });    
    });
});

my forms with foreach value.

<form method="post" action="">
<input id="v_w_id_value" type="hidden" name="v_w_id" value="OIUIUNKLJ" />
<input class="videoThumbS" type="button" name="selectSel" value="Select" id="selectbut" />
</form>

the value in the hidden i just insert it for example but it was loop to diff. value.

then it will insert to the database.

<?php
include ( 'class/conn.php' );
$v_watch_id = $_POST['v_w_id'];
$selected_videos = mysql_query( "INSERT INTO s_vids VALUE('', '$v_watch_id', NOW() )" ) or die ( mysql_error() );
?>

Inserting to the database was working but only the first value that was inserted, so when i click the second or third Select button it doesn’t read the jQuery.
how can i fix it?

Using the firebug on firefox console javascript i can see the different value of select button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:39:21+00:00Added an answer on June 7, 2026 at 5:39 am

    I found your explanation a little confusing, but I think you are saying you have repeated that form and its two input elements several times on the page, and when a particular “Select” button is clicked you want to submit its associated hidden value.

    If so, try this minor change to your function:

    var dataString = $(this).siblings('input[name="v_w_id"]').val();
    

    Within your click handler this is the clicked element, so $(this).siblings() gets the siblings of the clicked element and using the selector 'input[name="v_w_id"]' gets that particular sibling.

    The way you were doing it you were selecting the hidden input with id v_w_id_value, which meant it would always select the same one. The id attribute is supposed to be unique, that is, no two elements should have the same id – if you break this rule the browser usually displays the page OK anyway, but your JS won’t work properly: for most browsers selecting by the duplicated id will return the first element with that id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the callback of a HttpRequest I have, I run this jQuery code: $(input[value='+data.notetype+']).click();
i have this jquery code $(#eioShowLink).on('click',function(){ $(#ioEditRelatedConcepts).html(''); $.getJSON(http://localhost/Mar7ba/Ontology/getRelatedConceptsAndRelations/+conceptName+/TRUE, function(data){ var concepts = data[0]; var
Suppose I have this jQuery code. $(document).delegate('a[title]', 'click', function(event) { var txt = //
I have this code in jquery : $(#order_btn).click(function(){ var totalprice = $(.price_amount).text(); $(#totalprice).val(totalprice); });
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
first, have to look at this dragndrop ( http://code.google.com/p/jquery-drag-and-drop/ ) what i want to
Hi i want to get changed text value from JQuery but i can't select
First the code might suck as I'm new with JQuery. I have this html:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have this jQuery code in my JSP page (jQuery 1.7.2) : function Header()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.