bluedaniel Posted June 10, 2009 Share Posted June 10, 2009 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 Quote Link to comment Share on other sites More sharing options...
Maq Posted June 10, 2009 Share Posted June 10, 2009 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. Quote Link to comment Share on other sites More sharing options...
bluedaniel Posted June 10, 2009 Author Share Posted June 10, 2009 I have a function that requires the variable $userid in my handle page, that page just contains some post data but I need the script to also send the $userid variable as well. I have no clue how to pass variables from js Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted June 10, 2009 Share Posted June 10, 2009 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}); } Quote Link to comment Share on other sites More sharing options...
bluedaniel Posted June 10, 2009 Author Share Posted June 10, 2009 Im good enough at breaking down code to know thats the part that needed editing but I just dont know what parameters, sticking a variable which is already defined in php isnt difficult is it? Quote Link to comment Share on other sites More sharing options...
bluedaniel Posted June 10, 2009 Author Share Posted June 10, 2009 got it sorted now, my site is mainly php but this script is a very nice addition. how do i mark it solved? Quote Link to comment Share on other sites More sharing options...
Maq Posted June 10, 2009 Share Posted June 10, 2009 got it sorted now, my site is mainly php but this script is a very nice addition. how do i mark it solved? Do you mind sharing? Bottom left, right above "Quick Reply". Quote Link to comment Share on other sites More sharing options...
bluedaniel Posted June 10, 2009 Author Share Posted June 10, 2009 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! Quote Link to comment Share on other sites More sharing options...
Maq Posted June 11, 2009 Share Posted June 11, 2009 Thanks for posting your solution. Remember when posting code to surround your code tags. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.