i have a form with some hidden fields.....

index.php page....

<form id="addReplyForm" method="post" action="">
 <input type="text" id="target" name="commentreply" />
 <input type="hidden" id="session_id" name="session_id" value="" />
 <input type="hidden" id="page_id" name="page_id" value="" />
 <input type="hidden" id="firstName" name="firstName" value="" /> 
 <input type="hidden" id="lastName" name="lastName" value="" /> 
 <input type="submit" id="submitReply" value="Reply" />
</form>

when u user clicks on the text field to enter text i would like all the other values to be automatically filled in, with there session_id, the page_id, there name.

so that when it uploads to the database i get the persons relavent information.

these are my varibles to be put in values,

myVaribles.php page....

// some thing like this.....

$sessionid = $_SESSION['profile_id'];
$page_id = $_GET['id'];

q = "SELECT firstName, lastName FROM users WHERE id = '$sessionid'";
                                  
        $result = $mysqli->query($q) or die('error');
        
        if($result) {
            while($row = $result->fetch_object()) {
                  $firstname = $row->firstname;
                  $lastname = $row->lastname;
                                   
                             
            }
         }

so as u can see i have 4 varibles on myVaribals.php page that i want to grab and put into my form in index.php page when the user clicks on the text field.

my jQuery so far.....

$(document).ready(function(){

$('#target').click(function() {

    $('#session_id').val('');   
    $('#page_id').val('');
    $('#firstName').val('');
    $('#lastName').val('');
  
// dont know how to get the values in :(
  
}

please help me :)

You can use this method if you return your values as JSON.

I think you will need to run that PHP file through a .post() command, that will return the values you want, the session ID comes from php session, so you don't need to pass that with the post.

i have looked it up but i have nothing to send to get the values back, the values are already done i just need to retrieve them.

okay, give me a little bit. I have to finish this work and then I will write the pages for you.. :)

any help would be appreciated thanks :)

okay, I see where you are having your problem, before I go working on a longer solution, why wouldn't you just run the PHP code before the form and then add the values right away, since they are hidden. Then, you wouldn't need that click function at all.

<input type="hidden" id="page_id" value="<?php echo $page_id; ?>" />

do that for all the variables and you should be good..

I have to take off for lunch, but I will check up when I return and if you need this for some other reason, that's okay. I will work on a different solution for you..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.