Jump to content

Jquery onsubmit append/create new table td with form values before ajax


antonyfal

Recommended Posts

Hi..

I noticed thAT ONCE an ajax call is sent it will process regardless the page a profile user on my site is on..

 

What im trying to do is save time for my site user and when data is entered into a form and submited i want the data to appear directly to the table bellow the "new" form in the list form.. This will give the illusion that the data is already processed, and the user can move on.. while the table in the database is processed in the backend..

I have a seperate function/script that at logout time will only logout when the last ajax call is processed.., But will give the illusion that the profile has logged out by hiding all links..

 

The only problem i have is the function to parse the form values with selectlists, and inputs to a newly created tr/td row.. before the4 ajax call is made..

 

example code only as an explanation of what im trying to achieve: If you have other examples you can use those in your explanation if you want.

 

<script type="text/javascript">

    function get_me(type,ajax_page,value,did,name) 

    { 

 

<!-- here i want to put a function to parse the form values from "NewForm" to a new row in "ListFormtbl" table, before the ajax kicks in-->

 

jQuery('#loadingdiv').show();// this will be removed and the process will hapen in the background.

    jQuery.ajax({ 

    type: type, 

    url: ajax_page+name+"="+value,

    dataType: "text/html", 

    success: function(html){

jQuery('#'+did).html(html); // will be removed as the data will already be view in the table below, while in the background it is processed into the database..

jQuery('#loadingdiv').hide();// will be removed

    });

</script>

<div id="editdiv">

<form id="NewForm">

<table width="100%" id="editFormtbl" style="text-align:center">

</tr>

<th><label for="name">Street</label></th>

<th><label for="city">City</label></th>

</tr>

<tr>

<td><input type="text" name="street_description" id="street_description" /></td>

<td><select name="city" id="city" />

<option value="City1">city1</option>

<option value="City2">city2</option>

<option value="City3">city3</option>

<option value="City4">city4</option>

</select>

</td>

</tr>

</table>

<form>

</div>

<br>

<br>

<br>

<div id="listdiv">

<form id="ListForm">

<table width="100%" id="ListFormtbl" style="text-align:center">

<tr>

<th><label for="name">Street</label></th>

<th><label for="city">City</label></th>

</tr>

<tr>

<td>Some street</td>

<td>Some city</td>

</tr>

<table>

</form>

</div>

 

Thanks in advance..

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.