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 

?>

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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