1

I have the following code that takes the field "text1" and passes it to a php page that processes it. Despite the fact that I am aware of what to do on the php page for multiple text fields, I can't figure out this part below because I'm not that great at ajax...

So my question is, how do I convert the following code to make it work for 3 text fields instead of just one? (example, "text1, text2, text3")

Here is the code...

<script>
            $(document).ready(function () { 
        $('#submit').click(function(){
            var ths = this;
            var str = $(ths).siblings("#text1").val();

        $.post("saveData.php", {t:str}, function(value){
                $(ths).parent("#c").fadeOut("fast");
                $(ths).parent("#c").siblings("#cn").html(value);
        });
        });
});
</script>

1 Answer 1

1

you can pass multiple data in $.post(), like:

....
var str = $(ths).siblings("#text1").val(),
   str1 = $("#text2").val(),
   str2 = $("#text3").val();
$.post("saveData.php", {t:str, t2 : str1, t3 : str2}, function(value){
  ...
Sign up to request clarification or add additional context in comments.

2 Comments

okay, now that was so simple I feel dumber as to have asked that question. Gonna go stick my face in a tub of acid now. Jeesh!
Oh and THANKS. Appreciated much!

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.