Jump to content

Recommended Posts

Im using an Edit-In-Place script found here: http://24ways.org/2005/edit-in-place-with-ajax

 

(js file here: http://24ways.org/examples/edit-in-place-with-ajax/editinplace.js)

 

It works fine except I need another variable sent to the editing php handle file for database updating purposes.

 

The variable I need is $userid which is defined in the php form page.

 

Summary:

[*]Form page - user.php

[*]Ajax script - posts to useredit.php

[*]Editing handle - updates the database with post variables.

 

Thanks people, Im absolutley new to Ajax really

You claim the AJAX forum is dead and your thread hasn't even been here for 3 hours...

 

I don't see any question in your post, you just claim you need to send a variable but don't specify what you're having trouble with.

how much JS do you know ? See the comments below for a suggested solutions

 

function saveChanges(obj){

var new_content	=  escape($F(obj.id+'_edit'));

obj.innerHTML	= "Saving...";
cleanUp(obj, true);

var success	= function(t){editComplete(t, obj);}
var failure	= function(t){editFailed(t, obj);}

  	var url = 'edit.php';

  	//this variable holds your parameters, the ones being sent to PHP script...
  	//Modify this and you should be good to go...just concatenate the parameters & values you need to this line 
var pars = 'id='+obj.id+'&content='+new_content;     //this line//

var myAjax = new Ajax.Request(url, {method:'post', postBody:pars, onSuccess:success, onFailure:failure});

}

ok so

 

php file:  <?php echo sprintf( '<input type="hidden" name="hdnTest" id="hdnTest" value="%s" />', htmlentities( $userid, ENT_QUOTES ) ); ?>

 

javascript file:  var userid = ( document.getElementById( 'hdnTest' ).value ); //get the value

                    var pars = 'id='+obj.id+'&content='+new_content+'&userid='+userid; //send it to the third php page

 

thanks people!

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.