Jump to content

Collapsible <div> with JS


Nexy

Recommended Posts

Why Hello There!  :) The following code works fine to some extent.

 

<?php
$shomes = mysql_real_escape_string(stripslashes($_POST['shoutext']));
$sshuser = mysql_real_escape_string(stripslashes($_SESSION['username']));
$cshuser = mysql_real_escape_string(stripslashes($_COOKIE['user']));
$shtime = mysql_real_escape_string(stripslashes(date('h:i:s a')));
?>

<div class='create margin' style='font-size: .8em; width: 700px; margin-top: .8em; margin-bottom: 0'>
Shoutbox (

<a href="javascript:;" 
onmousedown="if(document.getElementById('shoutbox').style.display == 'none' && document.getElementById('shoutform').style.display == 'none') 
{ 
	document.getElementById('shoutbox').style.display = 'block'; 
	document.getElementById('shoutform').style.display = 'block'; 
}
else 
{ 
	document.getElementById('shoutbox').style.display = 'none';
	document.getElementById('shoutform').style.display = 'none'
}
">Show/Hide</a>
)
</div>

<div id="shoutbox" style="display:none">

<?php
	$shsql = "SELECT * FROM shoutbox WHERE id > 0 ORDER BY id DESC";
	$shres = mysql_query($shsql) OR die(mysql_error());

	while($shout = mysql_fetch_array($shres))
	{
		echo $shout['time'] . " " . $shout['user'] . ': ' . $shout['message'] . '<br />';
	}
?>

</div>

<div id="shoutform" style="display: none">

<?php
	if($_POST['shoutsub'] && $sherror == "1") { echo "<span style='color: red'>Please enter a message!</span>"; }
?>

<form action="#' method="post">
   <fieldset id='shout'>
   
	<label for="shoutext">Message:</label>
	<input type="text" id="shoutext" name="shoutbox" tabindex="6" style="width: 500px" />

	<input type="submit" id="shoutsub" name="shoutsub" value="Shout!" tabindex="7" />

    </fieldset>
</form>

</div>

<?php
if($_POST['shoutsub']) {
	if(!empty($shomes))
	{
		if($_SESSION['username']) {	mysql_query("INSERT INTO shoutbox(user, time, message) VALUES('$sshuser', '$shtime', '$shomes')"); }
		else if($_COOKIE['user']) { mysql_query("INSERT INTO shoutbox(user, time, message) VALUES('$cshuser', '$shtime', '$shomes')"); }
	}

	if(empty($shomes)) { $sherror = "1"; }
}
?>

 

The problem is, when I click submit, the url becomes something like this: http://divnx.net/index.php?shoutbox=&shoutsub=Shout!#%27%20method=

 

Thus, my php part is completely ignored. The collapsible div works just fine, only problem with the submit. Any help would be appreciated.

 

Thank You!  :)

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.