i have a textarea with alot of words in it. Is there an alternative way to send the words in the textarea to another page without using a form and submit button?

Recommended Answers

I'm not really sure what you're trying to do, but if you don't want the page to reload you can use AJAX (javascript) to send data across web pages asynchronously. It's a bit confusing if you're new at javascript, you can also use Jquery to make it easier for you.

Jump to Post

All 4 Replies

I'm not really sure what you're trying to do, but if you don't want the page to reload you can use AJAX (javascript) to send data across web pages asynchronously. It's a bit confusing if you're new at javascript, you can also use Jquery to make it easier for you.

Is there an alternative way to send the words in the textarea to another page without using a form and submit button?

Yes, you can use a PHP Session:

Grab text from textarea and put it into a session:

<textarea name="text"> </textarea>

<?php
    $texttosend = $_POST['text'];
    $_SESSION['textareatext'] = $texttosend;
?>

Print it out on the next page:

<?php echo $_SESSION['textareatext'] ?>

Something like this should work... but not sure

but without the <form>, the browser wouldn't know if it's using a $_GET or $_POST method, and without submitting the form no value can be sent to the server and PHP is a server side programming language.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
	function sendTextarea()
	{
		var text = escape(document.getElementById('tb').value);
		window.location.href='second.php?tb='+text;
	}
</script>

</head>

<body>
<textarea id="tb">this is text</textarea>
<input name="Pass" value="Go To Second Page" onclick="sendTextarea();" type="button" />
</body>
</html>

this is example code you can use.
hope it will help you.
even you can decode passing text using base64decode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.