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
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
You need a form field to create a POST variable. <input type=... >
http://innovationsdesign.net/wb_2.7/pages/tech-resources/php-help.php#question_8
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!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.