Jump to content

need help with dropdown and form table


hardikspider123

Recommended Posts

<script type="text/javascript">


//function getIt(){
//var i=$("#button3").val()
//alert(i);
//}


    $('#button3').click(function() {
//        $v1 = ($('#daycombo1').val());
//        alert($v1);
        
            grabVal();

    });
    
    
function grabVal() {

$('.hovertable tbody tr').each(function () {

     var s = $(this).find('.mycombo input').val();

        $('.mycombo1').find('option[value="' + s + '"]');

  

})

}  
    

    $('#button1').click(function() {
        iterate();
    });


    $(".mycombo").change(function() {
        ($(this).find("option:selected").text());
    });

    function iterate() {
        var values = [];

        $("input:checkbox").each(function() {
            var $this = $(this);
//             console.log($this);
            var selected = {};
            var $v = "";
            var counter = 0;
            if ($this.is(":checked")) {
                $v = $this.closest("td").siblings("td")

                if ($v.find("select").attr("class") == "mycombo") {
                    selected["memberid"] = $this.val();
                    selected['combo'] = $v.find("#combo :selected").text();
                    selected['daysadded'] = $v.find("#daycombo :selected").text();
                }
                else {

                }
                values.push(selected);

            } else {

            }
            counter++;
        });

        var dataArrayFields = {};
        //  dataArrayFields['command'] = 'forgotemail';
        dataArrayFields['params'] = values;
        var ob = (JSON.stringify(values));

        $.ajax({
            type: "POST",
            url: "update3.php",
            data: {pData: ob},
//            success: function(data2) {
//                whatToDo(data2);
//              
//            },
            success: function() {
                alert("Records Updated Suceessfully");
                location.reload(true);
//            $("#load").html(msg);

            },
            cache: false
        });



    }


    function whatToDo(status) {
        if (status == "success") {

//            echo "Record updated succesuufully";
            location.reload(true);
//
//            window.location = self;
        } else {

        }

    }


    $(document).ready(function() {
        $('.check:button').toggle(function() {
            $('input:checkbox').attr('checked', 'checked');
            $(this).val('Uncheck All')
        }, function() {
            $('input:checkbox').removeAttr('checked');
            $(this).val('Check All');
        })
    })



</script>


above is code for my checkbox table

 

 

 

 

<!--Add 30 Days-->
<input id='button3' type='button' class='move'    value='Add Days'   />
<select id="daycombo1" class="mycombo1">
    <option>SELECT</option>
    <option value="1">1</option>
    <option value="3">3</option>
    <option value="7">7</option>
    <option value="14">14</option>
    <option value="30">30</option>
    <option value="40">40</option>
    <option value="50">50</option>
    <option value="60">60</option>
    <option value="70">70</option>
    <option value="80">80</option>
    <option value="90">90</option>
</select>

Hi

 

I have dropdown box which has value in days like 1,3,5,7,10,30,40...

 

 

now I if I select from dropdown any value suppose 30 then (in my table there is one column name as add days which has dropdown too) it should update all values in dropdown  as 30.

 Please let me know.

 

 

Thanks in advance

 

 

 

 

 

 

Link to comment
Share on other sites

OK - I think I see what you're asking. You're going to want a change event handler for the dropdown outside the table that sets the value of the dropdown inside the table, something like this:

$('#ddOutsideTable').on('change',function(e){
	var curVal = $(this).val();
	$('#ddInsideTable').val(val);
});

Please note this is entirely untested code, so there may be a grammatical or logical err in there.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.