SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    populate form help

    hello
    i am trying to fire a form which after the call to retrieve the data, populate the form with the data. i can see from firebug that the json data is being captured, but cannot seem to be able to populate the form with it. i am using a jquery plugin facybox, that opens the form, but the fields are blank. i have attached my code and would be grateful if someone could tell me where i am going wrong? many thanks

    js code

    Code:
    <script type="text/javascript">
    function edit(com, grid) {
    if (com == 'Edit') {
            if($('.trSelected').length>0){
                if($('.trSelected').length>1){
                    alert('Please select just one row');
                    return;
                }
                var items = $('.trSelected');
                var itemlist ='';
                for(i=0;i<items.length;i++){
                    itemlist+= items[i].id.substr(3);
                }
    			$.ajax({
    			   type: "POST",
    			   dataType: "json",
    			   url: "tempcontact.php",
    			   data: "items="+itemlist,
    			   success: function(data){
    			   	document.getElementById('id').value = data.id;
                document.getElementById('email').value = data.email;
    			    
    			   $("#flex1").flexReload();
    			   }
    			 });
                
                /*and so on then you can call facybox*/
               jQuery.facybox({ div: "#editform"});
    		   
            } else{
                alert('Please select a row to edit.');
            }
        }
          }
    </script>
    form

    Code:
    <div id="editform" style="display:none;">
      <form action="conedit.php" method="post" class="webform">  
    <fieldset>  
    <legend><span>Update Contact</span></legend>
    <br /> <div id="dataText">Please delete the fields if there is no data 'No data to display'.</div>
      <label for="id">ID:</label>  
    <input id="id" name="id" class="text" type="text" value="" />
    <label for="name">Full Name:</label>  
    <input id="name" name="name" class="text" type="text" value="" />  
      
    <label for="email">Email address:</label>  
    <input id="email" name="email" class="text" type="text" value="" />  
      
    <label for="phone">Telephone:</label>  
    <input id="phone" name="phone" class="text" type="text" value="" />  
      
    <label for="mobile">Mobile:</label>  
    <input id="mobile" name="mobile" class="text" type="text" value="" />  
     
    <label for="fax">Fax:</label>  
    <input id="fax" name="fax" class="text" type="text" value="" />  
      
    <label for="notes">Notes:</label>  
    <textarea name="notes" cols="25" rows="3"></textarea>  
    
    
    </fieldset>
    <input class="submit" type="submit"  name="submit" value="Update" />
    </form>
    </div>

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can no-one offer any advice on this? thanks


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
  •