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.
ex:<form 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


<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>		

Sure, just echo it :slight_smile:



<form action="<?php echo $questionLIst->saveQuestion(); ?>" method="post"> 
[COLOR=#000000]

[/COLOR]

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());

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);

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.