Copy link to clipboard
Copied
I have a form with a question like: "How did you hear about us?" and a radio group with some choices. One of the radio group choices is "Other - please describe!". When selected, a text area changes from "read-only" and the user can write something. I am not able to update a record with user's selection in one table field (I can save either radio group selection or text area). Any help? Thank you!
You need to check the value of the selected radio button. If it's not "I have this answer:", assign the value to $_POST['Proposal_text'].
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
if ($_POST['Proposal'] != 'I have this answer:') {
$_POST['Proposal_text'] = $_POST['Proposal'];
}
$updateSQL = sprintf("UPDATE sarcini SET solutie_6=%s, introd_6=%s WHERE id_question=%s",
GetSQLValueString($_POST['Proposal_text'], "text"),
...
Copy link to clipboard
Copied
We need to see your webpage to be able to help you. Please post a link to your webpage that we can view on our browsers to help you resolve this.
Copy link to clipboard
Copied
Unfortunately it is not on Internet. But part of the code is this:
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE sarcini SET solutie_6=%s, introd_6=%s WHERE id_question=%s",
GetSQLValueString($_POST['Proposal_text'], "text"),
GetSQLValueString($_POST['Full_name'], "text"),
GetSQLValueString($_POST['id_question'], "int"));
mysql_select_db($database_dbconfig, $dbconfig);
$Result1 = mysql_query($updateSQL, $dbconfig) or die(mysql_error());
$updateGoTo = "Search_answer.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
And than:
<INPUT name="Proposal" type="radio" id="Proposal_0" value="No answer." checked="CHECKED">
No answer.
</label>
</div>
<p align="left">
<label>
<INPUT name="Proposal" type="radio" id="Proposal_2" value="E-mail answer.">
E-mail proposal</label>
</p>
<p align="left">
<label>
<INPUT name="Proposal" type="radio" id="Proposal_1" value="I have this answer:">
I have this answer:</label>
</p>
<p>
<label for="Proposal_text"></label>
<textarea name="Proposal_text" id="Proposal_text" cols="50" rows="6"></textarea>
I would like to update with: "No answer." , "E-mail answer." or, if id="Proposal_1" is checked, with the values entered by user in textarea "Proposal_text".
Copy link to clipboard
Copied
Moved thread to Developing Server-side applications in Dreamweaver for better responses.
Copy link to clipboard
Copied
You need to check the value of the selected radio button. If it's not "I have this answer:", assign the value to $_POST['Proposal_text'].
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
if ($_POST['Proposal'] != 'I have this answer:') {
$_POST['Proposal_text'] = $_POST['Proposal'];
}
$updateSQL = sprintf("UPDATE sarcini SET solutie_6=%s, introd_6=%s WHERE id_question=%s",
GetSQLValueString($_POST['Proposal_text'], "text"),
GetSQLValueString($_POST['Full_name'], "text"),
GetSQLValueString($_POST['id_question'], "int"));
Copy link to clipboard
Copied
Thank you! Simple and elegant!
Copy link to clipboard
Copied
You're welcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more