Ask questions and get good answers on mb.jQuery.components

Hi,

I am working on a one page website that has a search form. When someone submits their form I would like to use the onclick function to append the form values to the url that loads my content via Ajax. Something like this:

onclick="$('#demoContainer-store').mb_changeContainerContent('container-search/form-value1/form-value2');"

Ultimately, I need those values from the form to pull information out of my database via PHP.

Is it possible to append the submitted form values to the url or somehow pass the form data to the new container with the onClick function?

Thank you,

Jeff

asked Oct 03 '11 at 21:53

jwimpy's gravatar image

jwimpy
1


I figured this one out. For those that may have a similar issue, here's what I did:

I had two input boxes in my form with id=searchname and id=searchstate, respectively. Then I used this to append the values as $_GET variables:

<a id="searchform" href="#"  onclick="$('#demoContainer-store').mb_changeContainerContent('container-search?name=' + $('input#searchname').val() + '&state=' + $('input#searchstate').val());" style="cursor:pointer;">Find &raquo;</a>

answered Oct 04 '11 at 09:35

jwimpy's gravatar image

jwimpy
1

edited Oct 04 '11 at 13:29

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

Hi Jeff, this is a solution, anyway the mb_changeContainerContent accept two parameters, the first is the URL of the page to get via ajax, the second is the parameters you whant to pass: jQuery.fn.mb_changeContainerContent=function(url, data).

You can than pass your data as second parameter of the funxtion. Bye, Matteo

(Oct 04 '11 at 13:31) Matteo Bicocchi ♦♦

Thanks Matteo.

I read all the documentation I could find about passing data into mb_changeContainerContent by using the (url,data) method. That would be my preferred way to do it but I could never figure out the correct syntax and couldn't get it to work that way.

Great script!!

Regards,

Jeff

answered Oct 05 '11 at 07:33

jwimpy's gravatar image

jwimpy
1

Your answer
toggle preview

jQuery main site - Matteo Bicocchi