0

I'm using PHP , Yii. I have a 3 tabs tab1 tab2 tab3.

In every tab I have a drop-down field with the name type in it with different drop-down options according to the tab.

When I select first tab the other two tabs type fields of other tabs are hidden. Similarly in other tabs.

The problem is when I press search button all the three selected type values are shown in GET method like ?search[type]=130&search[type]=111&search[type]=111 which results in wrong search results.

I need not want to pass the hidden field values to GET method action. I'm not asking for code to do that. Is it possible to not to pass hidden field values? If so guide me.

NorthCat
  • 9,643
  • 16
  • 47
  • 50
SO-user
  • 1,458
  • 2
  • 21
  • 43

1 Answers1

-1

An HTML form submit will pass all fields to the requested action.

The only way I can see how you could do this is by using a combination of JavaScript and HTML.

Consider these two fields.

<input type='text id='field1' name='field1' value="">
<input type='text id='field2' value="">

Only field1 will be passed with the normal form submit button.

if you need to pass field2, you can use JavaScript and set up the values to be sent to the server. Using JQuery you would something like :

$.ajax({
    type: 'POST',
    url: 'http://place.your.url.here.com',
    data: { 
        'field1': $("#field1").val(),
        'field2': $("#field2").val(),
    },
    success: function(data){
        alert(msg);
    }
});

Therefore, what remains is to create another hidden fields that would indicate which tab you are on, which you set on click. Then, when sending your form, you create the POST values you need to send.

crafter
  • 6,246
  • 1
  • 34
  • 46