Jump to content

forms


Woodburn2006

Recommended Posts

i have a blog on one of my sites, but i want to be able to edit entrys using ajax. so that the user will click a link below the entry and the entry will reload into a textbox so that it can be edited. the text can now be edited then when submit is clicked the page reloads back to normal again with the edited post.

 

does anybody know any good tutorials or ways i can do this? i want a tutorial that explains everything so that iu can understand it and use it for other areas of the site.

 

thanks alot

Link to comment
Share on other sites

thanks for your suggestions but the inline editor looks good but is out of my league for now and i want to be able to understand it.

 

i have learnt bits of ajax, i have a working example of some i have done here: http://travelling.dw20.co.uk/?go=photos

 

but i think the main problem is that i do not understand how i can pass the form values through ajax into my php script. i have what i want working at the moment but just in php.

 

you can see an example here: http://travelling.dw20.co.uk

 

login as: egg

pass: egg

 

and edit a form post then you can see what i want to happen in ajax

Link to comment
Share on other sites

If you have an understanding of how Ajax works, than I would set up the script without the passing of the form values and post and we can help you further. 

 

If you want to send POST variables via AJAX, trying something like:

 

//Your opening form field

<form enctype="multipart/form-data" action="javascript:get(document.getElementById('myform'));" name="myform" id="myform" method="post">

//rest of your form

 

//functions (in same file as your AJAX requests)

function makePOSTRequest(url, parameters) {

xmlHttp=GetXmlHttpObject();

      if (xmlHttp==null){

alert ("Browser does not support HTTP Request");

return;

}

var url="pageinfo.php";

url=url+"?page=contact.php";

xmlHttp.onreadystatechange=function () {

stateChange("pagecontent");

};

      xmlHttp.open("POST",url,true);

      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

      xmlHttp.setRequestHeader("Content-length", parameters.length);

      xmlHttp.setRequestHeader("Connection", "close");

      xmlHttp.send(parameters);

}

 

function get(obj) {

var poststr = "submit=" + escape(encodeURI(document.getElementById("submit").value )) +"&dp=" + escape(encodeURI(document.getElementById("department").value )) +"&fn=" + escape(encodeURI(document.getElementById("firstname").value )) +"&ln=" + escape(encodeURI( document.getElementById("lastname").value ))+"&email=" + escape(encodeURI( document.getElementById("email").value ))+"&phone=" + escape(encodeURI( document.getElementById("phone").value ))+"&sub=" + escape(encodeURI( document.getElementById("subject").value ))+"&msg=" + escape(encodeURI( document.getElementById("msg").value ));

      makePOSTRequest('post.php', poststr);

}

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.