Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i want to add functionlity for a question and answer form using jquery ,html,php in which when a user clicks on the answer button then it will show him the textarea and takes the data from the textarea and when he fills the name then only the textarea get activated

What I have tried:

PHP
<?php //print_r($QuesAns);exit; ?>


	<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 hidden-xs bordered-row question-ans-drawer" id="js_ques_ans_template">
		<div class="ques-ans-sticky">
			<h3>All Questions</h3>
			<span class="ask-ques">
				<span class="ellipsis"><?php echo $adda['display_name']; ?></span>Ask a question 
			</span>	
		</div>
		
		<div class="ques-ans-wrapper">
			<ul>
				<?php foreach ($QuesAns as $QuesAns_key => $QuesAns_value) { 
					
					?>
				
				<li class="ques-container">					<div class="user-question">
						
						<div class="ques-details">
							<?php echo $QuesAns_value['userId']['firstName'].''.$QuesAns_value['userId']['lastName']; ?>  
								<small> <?php if ($QuesAns_value['lastmodifiedDate']) {
											echo $QuesAns_value['lastmodifiedDate']; }
											else{
												echo $QuesAns_value['creationDate'];
											}  ?>
								</small>
							
							<p><?php echo $QuesAns_value['question']; ?></p>
							
							<span class="abuse " title="Report as spam" id="abuse-<?php echo $QuesAns_value['id'];?>">report abuse</span> 
							<span class="js_answer">Answer</span>
						</div>
					</div>
					<div class="ans-list-section">
						
						
							
						
						<?php if (!empty($QuesAns_value['answers'])) {
								foreach ($QuesAns_value['answers'] as $answer_key => $answer_value) { 
									 ?>
						<ul class="ans-container">
							<li>								<div class="ans-content">
									
									<div class="ans-content-details">
										<?php echo $answer_value['userId']['firstName'].''.$answer_value['userId']['lastName']; ?><small> <?php echo $answer_value['creationDate']; ?></small>
										
										<p><?php echo $answer_value['answer']; ?></p>
										
										<span class="abuse" title="Report as spam" id="abuse-<?php echo $answer_value['id'];?>">report abuse</span>
									</div>
								</div>
							</li>							
						</ul>
						<?php
								}
							} ?>
						<span class="more-ans">12 more answers</span><?php 

						/*foreach ($QuesAns as $QuesAns_key => $QuesAns_value) { 
							if($QuesAns_value['stats']['answersCount'] > 2 && $QuesAns_value['stats']['answersCount'] != 0){ 

								 echo $QuesAns_value['stats']['answersCount'] 
							}
						}	*/

						?>		

								

					</div>
				</li>				<?php } ?>
			</ul>
		</div>
	</div>




	<div class="js_ask_ques" id="js_ask_ques_pop">
		<div class="user-login form-group">
			<img src="#" alt="" class="login-user-img">
			<div class="login-form-field">
				<input type="text" placeholder="enter email address" class="form-control">
				<input type="text" placeholder="enter your name" class="form-control">
			</div>
		</div>
		<div class="ques-section ans-section ">
			<textarea name="" id="" rows="3"></textarea>
			<span class="signup-link"><a href="javascript:;" class="js_ufdbk_login" class="">Log In</a> or Don't have an account? <a href="javascript:;" class="js_ufdbk_signup">Sign Up</a></span>
			<button type="submit" class="btn btn-success pull-right">Post</button>
			<button type="cancel" class="btn btn-default pull-right">cancel</button>
		</div>
	</div>

	



	<div class="ans-list-section ">
		
		<div class="ans-box">
			<div class="user-login form-group">
				<img src="#" alt="" class="login-user-img">
				<div class="login-form-field">
					<input type="text" placeholder="enter email address" class="form-control">
					<input type="text" placeholder="enter your name" class="form-control">
				</div>
			</div>

				
			<div class="ans-section">
				<div class="user-question">
					<img src="http://saurabh.jogurucdn.com/resources_version/desktop/img/default/user/t1/default_1_new.jpg" alt="" class="login-user-img">
					
				<span>&lt;?php echo $QuesAns_value['userId']['firstName'].''.$QuesAns_value['userId']['lastName']; ?>  </span>
				</div>
				<textarea name="" id="" rows="3"></textarea>
				&lt;!-- <span class="signup-link"><a href="#">log In</a>or Don't have an account? <a href="#">Sign Up</a></span> -->
				<button type="submit" class="btn btn-success pull-right">Post</button>
			</div>

		</div>
	</div>
Posted
Updated 12-Feb-18 1:55am
v2
Comments
David_Wimbley 10-Feb-18 2:03am    
So what is your question...all youve done is declare what you would like to do. If you are expecting us to do it for you, prepare for disappointment.

You ought to attempt the functionality you seek and do some research on your end to try and acheive that.

A simple google search would probably solve your issue and 90% of every issue you run into. keep in mind you can't expect a google search to yield results for your specific use case, rather you need to break your issue down into separate pieces, search google for this issues and then massage everything you've found into your code base to do what it is you need it to do.
Karthik_Mahalingam 10-Feb-18 3:15am    
add your code inside pre tag

1 solution

Just do it like it says here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900