Results 1 to 3 of 3

Thread: Problem with submitting forms using the DHTML Window Widget

  1. #1
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problem with submitting forms using the DHTML Window Widget

    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.
    Last edited by ddadmin; 12-05-2008 at 06:01 AM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please try and format any code in your post using the CODE tags. It just makes it easier to read.

    An easier way may be to set the DHTML window to IFRAME mode, and have the form results submitted directly inside the IFRAME of that DHTML window. The results to show would simply be what your form.php script returns.

    See this thread for info on how to change the target of a FORM so it points to a DHTML window with IFRAME mode: http://www.dynamicdrive.com/forums/s...ad.php?t=19083
    DD Admin

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    parucleo (01-18-2009)

  4. #3
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks a lot. think i might just have found the solution!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •