Script: DHTML Window widget (v1.1)
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/
Hey,
I'm trying to customise DHTML Window Widget version 1.1's Ajax DIV feature (as in the example: Window 3) to include html forms. This form would update/insert into my database. Finally the another the div would show a message confirming the submission.
The script goes as follows:
-------------------------------------------------------------------
-------------------------------------------------------------------Code:<script type="text/javascript"> function openmypage(){ ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", windowfiles/suggest_category.php", "Suggest a category for BMKP.org", "width=350px,height=200px,left=300px,top=100px,resize=1,scrolling=1") ajaxwin.onclose=function(){return true;} } </script> <p> Want to <a href="#" onClick="openmypage(); return false">suggest a category</a> </p> ------------------------------------------------------------------- Naturally, this script opens up a dhtml window on the web page. The script (suggest_category.php) for this window looks like this: ------------------------------------------------------------------- <div align="center"> <form id="myform" onsubmit="ajaxwin.load('ajax', 'windowfiles/submit_category.php', 'Suggest a category for BMKP'); return false" method="GET" action=""> <table cellpadding="" cellspacing="3"> <tr> <td align="left">Your name*: </td> <td align="left"><input type="text" name="name" /></td> </tr> <tr> <td align="left">Email Address*: </td> <td align="left"><input type="text" name="email" /></td> </tr> <tr> <td align="left">A category you think should be added*: </td> <td align="left"><input type="text" name="cat" /></td> </tr> <tr> <td align="left">Cite a reason: </td> <td align="left"><textarea name="reason" rows="" cols="15"></textarea></td> </tr> <tr> <td align="left"></td> <td align="center"><input type="submit" value="Suggest" /></td> </tr> </table> </form> </div> ------------------------------------------------------------------- Now, this div does open up the page as the form attribute requires (submit_category.php) where upon receiving all the necessary form fields inserts the data into the mySQL database. But the problem is i can't make the form (above) to submit the name-value pairs to the next window (submit_category.php). The script for submit_category.php looks like this: ------------------------------------------------------------------- <?php if(!isset($_GET['name'],$_GET['email'],$_GET['cat'])) { ?> <div align="center"> You did not provide any information for one/more field(s). Please go <a href="#" onClick="ajaxwin.load('ajax', 'windowfiles/suggest_category.php', 'Suggest a category for BMKP.org'); return false">back</a> and fill in all the required field(s). </div> <?php } else { $name=$_GET['name']; $email=$_GET['email']; $cat=$_GET['cat']; $reason=$_GET['reason']; include '../db/parameters.php'; include '../db/open.php'; $sql = "INSERT INTO suggest_category ( author, category_name, reason, email, status ) VALUES ( '$name', '$cat', '$reason', '$email', 'c' )"; mysql_query($sql,$conn) or die(mysql_error()); include '../db/close.php'; ?> <div align="center"> Thank you for your suggestion! You may now click the [X] key to exit this window. </div> <?php } ?>
Can someone kindly help me out? Thanks in advance.![]()



Reply With Quote

Bookmarks