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

how would i put a div value into a variable?

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>

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!

Be a part of the DaniWeb community

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