EvilLS1
06-25-2003, 02:56 AM
Hi,
Last night I started working on what I believe will be a very useful hack. It will allow you to directly reply (with a quote) to any post in a thread without having to load the newreply page..
In each post will be a small "QuickQoute" button.. When you click it a reply box will instantly drop down below that post.
I've put together an html example to show you exactly what I'm talking about.
Note: View this with Internet Explorer (6.0)... I haven't got around to making it work with other browsers but that won't be a problem.
Click here to see how QuickQoute works. (http://modernmusclecars.net/QuickQuote.html) (Click the QuickQuote button).
Anyway, what I will do is add some code to functions.php to check permissions, and then if everything is all good a variable will call the "QuickQoute" template which contains the reply form.. This variable will be placed in the postbit template.
Adding the PHP code isn't a problem.. I already know how to do that.
This is the problem:
Each form must have a unique ID or it will not work.. So I need to place some kind of variable that will display a unique value inside the javascript function.
Making it work in an HTML page is easy because you can define each form id yourself.. But making it work in the postbit is a bit more of a challenge because each postbit is generated dynamically (the same form will show up in each post).
Originally I planned to use the postid since it would be unique for every post, but I soon realized that php variables will not work in javascript functions.
Here's an example to show you what I need:
Example:
-----------------------------------------------
<script language="javascript">
function showDiv(objDiv)
{
Obj=eval((navigator.appName=="Netscape")?"document.layers['"+objDiv+"']":"document.all['"+objDiv+"'].style");
Obj.visibility="visible";
}
function hideDiv(objDiv)
{
Obj=eval((navigator.appName=="Netscape")?"document.layers['"+objDiv+"']":"document.all['"+objDiv+"'].style");
Obj.visibility="hidden";
}
</script>
<form enctype="multipart/form-data" action="newreply.php" name="vbform" method="post" onSubmit="return validate(this)">
<INPUT type="button" size="1" value="QuickQuote" name=button1 onClick="javascript:showDiv('formIDvariable ')">
<INPUT type="button" value="Hide" name=button2 onClick="javascript:hideDiv('formIDvariable ')">
<div id="formIDvariable " style="visibility:hidden;position:absolute">
~~~~~Reply Form goes here~~~~~
</div>
-------------------------------------------------------
Basically what I need is some way to change the form ID variable (highlighted in orange) to something unique for each post. The $post[postid] would be perfect if it were possible to make a php variable work with a javascript function, but that won't work. So I'm wondering if there's any way to do this with javascript?
I hope I've explained this clearly, but if you have no idea what the heck I'm talking about just let me know and I'll try again.
Any help would be appreciated.
Last night I started working on what I believe will be a very useful hack. It will allow you to directly reply (with a quote) to any post in a thread without having to load the newreply page..
In each post will be a small "QuickQoute" button.. When you click it a reply box will instantly drop down below that post.
I've put together an html example to show you exactly what I'm talking about.
Note: View this with Internet Explorer (6.0)... I haven't got around to making it work with other browsers but that won't be a problem.
Click here to see how QuickQoute works. (http://modernmusclecars.net/QuickQuote.html) (Click the QuickQuote button).
Anyway, what I will do is add some code to functions.php to check permissions, and then if everything is all good a variable will call the "QuickQoute" template which contains the reply form.. This variable will be placed in the postbit template.
Adding the PHP code isn't a problem.. I already know how to do that.
This is the problem:
Each form must have a unique ID or it will not work.. So I need to place some kind of variable that will display a unique value inside the javascript function.
Making it work in an HTML page is easy because you can define each form id yourself.. But making it work in the postbit is a bit more of a challenge because each postbit is generated dynamically (the same form will show up in each post).
Originally I planned to use the postid since it would be unique for every post, but I soon realized that php variables will not work in javascript functions.
Here's an example to show you what I need:
Example:
-----------------------------------------------
<script language="javascript">
function showDiv(objDiv)
{
Obj=eval((navigator.appName=="Netscape")?"document.layers['"+objDiv+"']":"document.all['"+objDiv+"'].style");
Obj.visibility="visible";
}
function hideDiv(objDiv)
{
Obj=eval((navigator.appName=="Netscape")?"document.layers['"+objDiv+"']":"document.all['"+objDiv+"'].style");
Obj.visibility="hidden";
}
</script>
<form enctype="multipart/form-data" action="newreply.php" name="vbform" method="post" onSubmit="return validate(this)">
<INPUT type="button" size="1" value="QuickQuote" name=button1 onClick="javascript:showDiv('formIDvariable ')">
<INPUT type="button" value="Hide" name=button2 onClick="javascript:hideDiv('formIDvariable ')">
<div id="formIDvariable " style="visibility:hidden;position:absolute">
~~~~~Reply Form goes here~~~~~
</div>
-------------------------------------------------------
Basically what I need is some way to change the form ID variable (highlighted in orange) to something unique for each post. The $post[postid] would be perfect if it were possible to make a php variable work with a javascript function, but that won't work. So I'm wondering if there's any way to do this with javascript?
I hope I've explained this clearly, but if you have no idea what the heck I'm talking about just let me know and I'll try again.
Any help would be appreciated.