www.webdeveloper.com
Results 1 to 6 of 6

Thread: pre-load form then populate after submission

  1. #1
    Join Date
    Nov 2002
    Posts
    14

    Exclamation pre-load form then populate after submission

    Wow, its been years since i was last here. I love the layout of the site now - great job

    I was tasked with streamlining our client-side support area. The way i have it now is this:

    The page is displayed with all the user's open and closed tickets
    user clicks on the topic via url link
    a new tab or window opens with the information displayed

    I need to change this so that when the person hits a button, the ticket opens on the existing page. Once they answer it or do whatever to it, the ticket will close and the page goes back to displaying tickets again.

    I don't have much code at all, other than a div and the httprequest code. I don't really use javascript at all, other than the occassional script i get from other sites. I know i may not be able to do what i'm trying to discribe, i'd be happy if i could i pre-load the form in a collapsed box, then have ajax get the information needed and load it into the appropriate areas. Any help would be greatly appreciated.

  2. #2
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    I finished an encrypted-note, Version fetch, for my site using AJAX. The button is a little title within a <div id=vdiv>.

    Here is the callback function I setup for AJAX. I got it to call Flist2 with the "data" it received. Flist2 happens to be the third stage of a finite state machine to control the sequence.

    Code:
     
    var Flist2=function (data){Leaves[sentFORrn]=Ltrim(data);
    var ptag=document.getElementById('IN4');if(!ptag)return(false);ptag.value=Leaves[sentFORrn];
    ST.innerHTML='<div><ul><li><a href="#" onclick="manyList(3)">show</a></li><li><a id=ml1 href="#" onclick="manyList(2)">'+atVer1+'</a></li><li><a href="#" onclick="manyList(1)">\<\<</a></li><li><a href="#" onclick="manyList(11)">\>\></a></li><li><a id=ml9 href="#" onclick="manyList(12)">'+atVerN+'</a></li><li><a href="#" onclick="manyList(13)">show</a></li></ul><br></div>';
    if(lastML==13)manyList(11);
    if(lastML==3)manyList(1);
    }
    ST, has the NodeReference for the div (ST=document.getElementById("vdiv");

    I am showing you the snippet to demonstrate how to get the form into a div on a button push.

    You will have to convert the formX.submit() to AJAX.

  3. #3
    Join Date
    Nov 2002
    Posts
    14
    Getting the data isn't the issue, i use something similar already to put a pre-defined template into a textarea. The problem is how to have the div hidden, then open automatically, and then close again after the ticket is submitted or closed.

    I use this script
    Code:
    <script language="javascript" type="text/javascript">
    <!-- 
    //Browser Support Code
    function ajaxFunction(){
    	var ajaxRequest;
    	
    	try{
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    			}
    		}
    	}
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4){
    			var ajaxDisplay = document.getElementById('n_answer');
    			ajaxDisplay.innerHTML = ajaxRequest.responseText;
    		}
    	}
    	var a_id = document.getElementById('danswer').value;
    	var queryString = "?a_id=" + a_id;
    	ajaxRequest.open("GET", "ajax_query.php" + queryString, true);
    	ajaxRequest.send(null);
    }
    
    //-->
    </script>
    and this is to select it
    Code:
    <div style="float: right;">
    			<select name="danswer" id="danswer" >
    		<?php
    		$ans = mysql_query("SELECT * FROM venzo_contactus_answers") or die(mysql_error());
    		while($row = mysql_fetch_array($ans)) {
    			echo "<option value='$row[id]'>$row[name]</option>";
    		}
    		unset($row);
    		
    		?>
    			</select>
    			<input type="button" id="a_select" name="select" value="Select" onclick="ajaxFunction();"/>
    		</div>
    I figured i might be able to reuse it, but i don't know enough about what i'm looking at to get the div opened and closed again.

  4. #4
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    I use the containing div of the button to process all the action. The AJAX submit buttons disappear on a single request which saves writing multi-threading AJAX requests.

    If your buttons remain visible I sugggest synchronous calls to the server via AJAX.
    Code:
     
    <div id="vdiv" style='font-size:xx-small;'><a href="#" onclick='return(WyCnotesVersion(this))'>Version?</a></div>

  5. #5
    Join Date
    Nov 2002
    Posts
    14
    This is all pretty foreign to me, but could something like this http://www.javascriptsource.com/form...form-1551.html (not the form part, just the js script) be combined with what i have already?

    The ticket view looks like

    ticket id status opend on topic answered by last updated
    int_1243 open 2012-03-13 21:35:30 test admin 2012-03-24 03:23:13 View button
    Last edited by Richei; 03-25-2012 at 05:29 PM.

  6. #6
    Join Date
    Nov 2002
    Posts
    14
    Well, i couldn't do it like i wanted, but i was able to adapt the code above to suit our needs.

    Thanks for the help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles