SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    153
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    reference a object->method <from action="<?php object->method ?>" ????

    Hello everybody,

    I have question and answer script below and as of now it just pulls the information from the database. what I like to do is have the ability to submit a question and refresh the div tag questiondev without refreshing the whole page.

    questions
    Is it possible to reference a object->method in side a form tag? I tried and didnt work.
    exform action="<?php $questionLIst->saveQuestion(); ?>" method="post">
    and save the data. i have a method setup to save.

    the reason behind this question is that later i like to use a ajax to refresh the question div tag to reload the questions and answer so that it becomes visible on the spot.

    any help you can provide would be greatly appreciated. thanks

    PHP Code:
    <div id="questiondev" >    
        <div> <center> Communication Center(Questions & Answers) </center></div>
        <?php
            
    foreach($questionList->displayQuestions() as $row
            {    if(!empty(
    $row['merchantid']))
                {    echo  
    '<div id="questionAsk">' 'By: <b> ' $row['merchantname']. '</b> 
                    <hr><br/>' 
    $row['question'] . '</div> '
                            }
                else 
                {    echo  
    '<div id="questionAnswer">' 'Project Id: <b> '.$row['projectid'] . '</b><hr>
                                     <br/>' 
    $row['question']  . '</div> '
                            }    
            }
        
    ?>
           <div id="questionButton">
            <form action="<?php $questionLIst->saveQuestion(); ?>" method="post">
                <hr> 
                <TEXTAREA NAME="saveqa" ROWS="3" COLS="50" MAXLENGTH="256"></TEXTAREA>
                <BUTTON NAME="btn_save">Ask</BUTTON>
            </form>
        </div>
    </div>

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,181
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Sure, just echo it

    Code:
    <form action="<?php echo $questionLIst->saveQuestion(); ?>" method="post">


  3. #3
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    153
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help.

    that was too easy..lol

    another problem the php code in the form tag seem to hide the textfield and the button but if i take out the php code its back to normal... what am i missing?


    Quote Originally Posted by K. Wolfe View Post
    Sure, just echo it

    Code:
    <form action="<?php echo $questionLIst->saveQuestion(); ?>" method="post">


  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,181
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by robin01 View Post
    Thanks for your help.

    that was too easy..lol

    another problem the php code in the form tag seem to hide the textfield and the button but if i take out the php code its back to normal... what am i missing?
    Pleae run the following right before your form and let us know the return:


    var_dump($questionLIst->saveQuestion());

  5. #5
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    153
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi K. Wolfe,

    i'm not pulling in any information rather sending information to be saved or processed. i have a method in the class called saveQuestion which will save the information to a database.

    $questionLIst->saveQuestion($projectid, $merchantid, $comments);

    Quote Originally Posted by K. Wolfe View Post
    Pleae run the following right before your form and let us know the return:


    var_dump($questionLIst->saveQuestion());

  6. #6
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,397
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Hi robin01,

    It's not possible to do what you're trying to do just with pure php - any php code is run on the server before the page is sent to the browser, so you can't use it to process user input unless you send the data back to the server (i.e. refresh the page). What you could do is use javascript to send the form data to the server, and then update the page without needing to reload it.


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
  •