Hello,
Can anyone help me complete this? Is this an array? - <?php
-
$Choice1 = $_POST['Choice1'];
-
$Choice2 = $_POST['Choice2'];
-
$Nothing = $_POST['Nothing']
-
I have an HTML file that will have a radio button and a text input
that looks like this.
Would you like to help me?
Yes or No
If yes, post choice 1
if no, post choice 2.
If left blank show nothing.....
13 5043
please go easy on me, i'm new :)
Dormilich 8,658
Recognized Expert Moderator Expert
doesn’t assigning the appropriate values do the trick?
well, sorry about this, I failed to mention that I would like to have a multiple question. Would be like this.
Would you like to help me now?
If yes , post choice 1
if no , ask another question.
Thanks for helping, please choose 2 options
Yes or no.
Then post :
# $Choice1 = $_POST['Choice1'];
# $Choice2 = $_POST['Choice2'];
# $Nothing = $_POST['Nothing']
Dormilich 8,658
Recognized Expert Moderator Expert
what does the according HTML look like? (hard to imagine right now)
does that make any sence?
I'm just trying to ask a question if value" NO" then SHOW " another question"
if YES or NO then display $whatever value.....
I would only like the second question to display only if you selected "NO" so it will need to hide. Is this possible with PHP ? or do I need a JAVA script?
I'm not exactly sure to ask the 2nd question in HTML or I guess to hide it - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html>
-
<head>
-
<form form action="help.php" method="post">
-
<form>
-
-
-
<b>Would you like to help me?</b>
-
-
<input type="radio" name="group1" value="Yes"> Yes<br>
-
<input type="radio" name="group2" value="Water"> No<br>
-
-
<input name="Choice1" type="text" />
code green 1,726
Recognized Expert Top Contributor
You need common name attributes when using radio buttons - <input type="radio" name="group" value="Yes"> Yes<br>
-
<input type="radio" name="group" value="Water"> No<br>
-
Thanks for correcting that. Is there a way to hide a question in HTML?
zorgi 431
Recognized Expert Contributor
I am not sure if this code is here just by copy/paste accident -
<form form action="help.php" method="post">
-
<form>
-
but just in case it probably should look like this: -
<form action="help.php" method="post">
-
</form>
-
Notice closing <form></form>
And also all of your form elements (like radios) should be within those tags. Now.... I do not think this are php issues at all
Thanks, for that , that was a typo too. I'm just not good at details :) I do have the script working just fine,my problem is that I'm trying to incorporate if you choose "NO" on the radio button, I'd like for a HTML/PHP to show another "Text" or "Ask " another question. I'm thinking about a list function. But it did not work, how I wanted it to. Perhaps I don't know what function it suitable for what I am trying to accomplish. - <?php
-
$my_array = array(Yes","No","Nothing");
-
-
list($Choice1, $Choice2, $Nothing) = $my_array;
-
echo "You selected Choice #2, the 2nd question would should here $Choice1, a $Choice1 and a $Nothing.";
-
?>
I feel like I'm still missing something here.
I think I may have got it.
Could I use this or is there another easier way to do this?
Example 1 question depending on answer ask another question and so on. -
>?php
-
$my_array = array("My Question #1 ","My Question # 2"," No question-blanks");
-
-
list($a, , $c) = $my_array;
-
echo "Here I only use the $a and $c variables.";
-
?>
-
-
The output of the code above will be:
-
Here I only use the My Question #1 and No question-blanks.
-
Zorgi or code green, would you guys be able to help me understand how to get a Multiple Yes or No Question in HTML to work with the array I built using selective questions if chosen " no or "yes" to show the output on the array following another question
to display anything on the array?
I think this would solve the problem, if the List function /array is the way to go for Yes or No, then multiple questions based on yes or no selection.
Thanks much!
Or anyone else that understands in this matter.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Flanagan |
last post by:
Of course "echo" is working, but I've got a case where php doesn't
seem to be sending out the result of an "echo." I'm probably doing
something wrong, but I can't see it.
I've got the following...
|
by: Marco |
last post by:
I have a couple pages that have tables, whats best use echo to produce the
full table with the variables or is it best to just make the table in plain
html and use <?php echo ('$va'l); ?> when i...
|
by: Domestos |
last post by:
Here an unusual one...
Say i am writing a few lines of code in php script as so...
<?php
echo '<table>';
echo '<tr>';
echo '<td> blah blah </td>';
echo '</tr>';
echo '</table>';
|
by: M |
last post by:
Hi,
Suppose you have the situation where you have say 20 blocks of text (~250
chars each) in a MySQL db that you need to display, but each has a condition
to check to see whether you should...
|
by: Jon Slaughter |
last post by:
I have some code that loads up some php/html files and does a few things to
them and ultimately returns an html file with some php code in it. I then
pass that file onto the user by using echo. Of...
| |
by: Odisey |
last post by:
Hello,
I am still getting these concepts. Help me learn. What is wrong here? Most echos are for testing.
Thank you,
Odisey
<?php #index php script 3.4
|
by: prosad |
last post by:
hi;
i have two tables in MySQL with:
1. TABLE(stat) column(c_id, FOREIGN KEY) referencing
2. TABLE (complaint) column (id_complaint, PRIMARY KEY).
TABLE (complaint) also contain a second...
|
by: rawky1976 |
last post by:
Hi, I have a hyperlink which goes to the page below and passes the PK_ID from a query into 'userid'. From this we query the DB and then echo a table with a form; only the textboxes are already...
|
by: webandwe |
last post by:
Hi,
I got the page login.php that have a script that logs you in and then go to loggedin.php with a piece of code to validate your loged in.
The validate stores the username, how can I echo the...
|
by: Request-1 |
last post by:
hi folks,
html coder here, new and terrified * of php!!
aaaaaa!
i'm trying to bury a JS script to rotate a photo, in a page i converted from
html to php.
the conversion went well, it was to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |