Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
Form post within an switch

Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
New one
New one

Joined: 04 Aug 2008
Posts: 1

PostPosted: Mon Aug 04, 2008 4:44 pm    Post subject: Form post within an switch Reply with quote

I'm pretty new to ajax, but I'm a quick learner and here is my test application.

To keep it short:
I have a simple main screen with 3 option. Add, Update, Delete.

You click Add and It loads a form under these 3 options. Pretty easy, but I don't know how to submit the form to that case. I had the form posting to itself originally, but once I load the form using a get ID tag, the form breaks unless the action is set to the file location. I want this form to submit within the page without redirecting.

Here's some relevant code:
<body onload="init()">
<div id="load">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>

<a href="#" class="tabs" id="additions">Additions</a><br /><br />

<a href="" class="tabs" id="update">Update Entries</a><br /><br />

<a href="" class="tabs" id="delete">Delete</a><br /><br />


<div id="Postjax" class="clearer"></div>


function init () {
   var tabs = document.getElementsByClassName('tabs');
   for (var i = 0; i < tabs.length; i++) {
      $(tabs[i].id).onclick = function () {

function getTabData(id) {
   var url = 'ajaxSwitch.php';
   var rand   = Math.random(9999);
   var pars   = 'id=' + id + '&rand=' + rand;
   var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );

function showLoad () {
   $('load').style.display = 'block';

function showResponse (originalRequest) {
   var newData = originalRequest.responseText;
   $('load').style.display = 'none';
   $('Postjax').innerHTML = newData;


if (isset($_POST['submit'])) {   

   $con = mysql_connect([REMOVED], [REMOVED], [REMOVED]);

   if (!$con)
     die('Could not connect: ' . mysql_error());
   mysql_select_db([REMOVED], $con);



<div style="width:600px;">




} else {


<form method="post" action="form.php">


<input type="submit" name="submit" value="Send">

<?php } ?>

Ajax Switch/Case:

if ($_GET['id'] == 'additions') {

   switch($_GET['id']) {

      case 'additions' : include_once('Form.php');
//case 'update' : include_once('upForm.php');
//case 'delete' : include_once('delForm.php');
      default: echo 'There was an error.';


//print $content;


Any help, suggestions, and/or new methods would be greatly appreciated.


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 XML & Copyright Notice 

Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X

Link to our site:


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos

Normal Bookmark

Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax

Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?

it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert