Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Radio group and textarea selection

Community Beginner ,
Oct 15, 2012 Oct 15, 2012

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!

TOPICS
Server side applications
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 15, 2012 Oct 15, 2012

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"),

                     

...
Translate
LEGEND ,
Oct 15, 2012 Oct 15, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 15, 2012 Oct 15, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2012 Oct 15, 2012

Moved thread to Developing Server-side applications in Dreamweaver for better responses.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2012 Oct 15, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 15, 2012 Oct 15, 2012

Thank you! Simple and elegant!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 16, 2012 Oct 16, 2012
LATEST

You're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines