Jump to content

PHP & AJAX, Fun With Textareas..


Solarpitch

Recommended Posts

Hey,

 

I'm looking to see whats the best way of submitting an array of textareas and passing the array via an Ajax request. Basically, I could have a form with 2,4,6 whatever amount of textareas, it's dynamic.

 

When I submit the form I want to get all the values of the textareas and pass through an Ajax request. Here's where I'm at.

 


// This is a snippet of the code I use, I do a str_replace and put in textareas, but that bits not important

$replacements[3] = '

<!--SYSTEM-->

<textarea name="free[]" id="free[]" ></textarea>
<textarea name="free[]" id="free[]" ></textarea>

<!--ENDSYSTEM-->
';

// Then my Ajax

$(function() {
$(".save_newsletter").click(function() {

	var id = $(this).attr("id");

                // I'm stuck here with how I get the array of textarea values and pass to Ajax below.


	var dataString = 'reply_content='+ val +'&title=' + title;

	$.ajax({
		type: "POST",
		url: "<?php echo site_url(); ?>newsletter/save_newsletter/"+id,
		cache: false,
		data: dataString,
		success: function(html){

			 $('#message').append("Saved!"); 
		}
		});
	 return false;
});
});


Link to comment
https://forums.phpfreaks.com/topic/237567-php-ajax-fun-with-textareas/
Share on other sites

You're having problems getting the values to PHP, right? It's not a PHP problem if PHP isn't involved.

 

Correct! .. Each textarea will need to have it's own id but will need to be dynamic in some way. Umm.. I'm gonna play with something here see if I can get this working

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.