Jump to content

Grabbing from <textarea> no problem, but what about a CSS box?


soma56

Recommended Posts

I'm familiar with getting/using my output from a <textarea> like so:

 

<form action="" method="post">
<table width="500">
<tr><td>What's your name?<input name="name" type="text" /></td></tr>
<tr><td><input type=Submit value="Enter Name" name="Submit"></td></tr>
</table></form>
<?PHP

echo "<textarea name=\"mytextbox\">";

unset($name);

if (isset($_POST['Submit'])) {

echo $name;

}

echo "</textarea>";

//Use 'name' for other php functions 

?>

 

However, can this be done with a CSS box? Here's an example:

 

<style>
div#status {position:absolute; overflow:auto; height:250px; background-color:#999; top:230px; font-family:Verdana, Geneva, sans-serif; font-size:10px; color:#333; margin-left:540px; width:240px; border:2px lightblue solid;}
</style>
<html>
<body>

<form action="" method="post">
<table width="500">
<tr><td>What's your name?<input name="name" type="text" /></td></tr>
<tr><td><input type=Submit value="Enter Name" name="Submit"></td></tr>
</table></form>
<?PHP

echo "<div id=\"status\">";

unset($name);

if (isset($_POST['Submit'])) {

echo $name;

}

echo "</div>";

//Use 'status' for other php functions 

?>

I still can't figure this out. Here's a correction on the original code:

 

<form action="" method="post">
<table width="500">
<tr><td>What's your name?<input name="name" type="text" /></td></tr>
<tr><td><input type=Submit value="Enter Name" name="Submit"></td></tr>
</table></form>
<?PHP

echo "<textarea name=\"mytextbox\">";

unset($name);
if (isset($_POST['Submit'])) {
$name = trim($_POST["name"]);
echo $name;
            
}

echo "</textarea>";

//Use 'name' for other php functions

?>

 

It seems PHP is able to grab everything from a text box based on the

<input name="name"

attribute. Does any such element work for div tags in CSS? I have everything styled in CSS with divs for boxes however the only way to use PHP as a means of playing with the output is by grabbing the name within a <textarea>.

 

I tried wrapping a visibility:hidden; within the code but that made everything hidden.

 

I saw somewhere that someone assigned a name to a div tag

<div id="mydiv" name="myname"

however I wasn't able to use the contents in a similar fashion as a <textarea>

 

I also tried wrapping the textarea within the CSS however that made everything look terrible.

 

PHP doesn't "grab" data from a screen, it is sent data from a form. PHP doesn't know anything about what's on the screen. If you want to send data to PHP from other places on the screen, you would have to use Javascript and send the data via AJAX.

 

Ken

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.