0

i have a div like

<form method='post' action='send'><div id='fail' name='cool'>300</div><input type='submit' value='submit'></form>

now how would i call that into a variable in php? i tried

$cool=$_POST['cool'];

but it didnt work. help

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by morteza_ipo
0

try this

<div id='fail' name='cool'>300</div>
<form method="post" action="send.php" name="form1">
<input type="hidden" name="field">
<input type='submit' value='submit' onclick="document.form1.field.value=document.getElementById('fail').innerHTML">
</form>
0

Test it!

<html>
<head>
<script language="javascript">
function send()
{
document.getElementById('div_content').value = document.getElementById('content').innerHTML;
document.forms['form1'].submit();
}
</script>
</head>
<body>
    <?php
    if($_POST)
    {
        echo $_POST['div_content'];
    }
    ?>
    <form name="form1" action="" method="post">
        <input type="hidden" id="div_content" name="div_content" />
        <div id="content">this is test</div>
        <input type="button" onclick="send()" value="Send" />
    </form>
</body>
</html>

By javascript I put div content ("innerHTML") into hidden tag!
And after that by javascript I send my from!

Edited by morteza_ipo: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.