Jump to content

Tree Structure


sandy1028

Recommended Posts

Hi,

 

How to get the tree structure of the value.

Any one please help about this

 

How to pass the value from radio button

<code>

<?

echo "<form action=\"optiontable.php?\" name=optionform>";

echo "<body bgcolor=\"#FFF0FF\" text=\"#000000\">";

echo "<div style=\"position:absolute; left:45px; top:80px;\">";

echo "<font size=\"4\"><u>View options</u></font>";

echo "<p><b>Table</b><input type=\"radio\" name=\"name\" value=\"table\">";

echo "</p>";

  echo "<p><b>Tree</b>  <input type=\"radio\" name=\"name\" value=\"tree\">";

  echo "</p>";

echo "<input type=submit value=\"Submit\">";

 

?>

</code>

Link to comment
https://forums.phpfreaks.com/topic/60724-tree-structure/
Share on other sites

Two tricks first.

1) When using double quotes in forms and things like that, use echo with a single quote, then you don't need \.

2) Use [ code ][ /code] its, not php, the bccode has to get phrased trough the system, then it's converted to html.

 

 

Now I'll help you..

Problems:

echo "<form action=\"optiontable.php?\" name=optionform>";

Why is the ? there, and why doesn't name have quotes but action does?

You also did not specify a method, so it will take default settings and make it get.

 

echo "<p>Table<input type=\"radio\" name=\"name\" value=\"table\">";
echo "</p>";
  echo "<p>Tree  <input type=\"radio\" name=\"name\" value=\"tree\">";
  echo "</p>";
echo "<input type=submit value=\"Submit\">";

Again with the name not quoted, and the type.

 

Now for the actual piece for scripting you want.

You basically want to let the client be able to select one element.

And then they submit the entry and then they will get shown the entry they chose.

 

<?php
  if (isset($_POST['Submit'])) {
      // The form has been subitted.
      if (empty($_POST['name'])) {
          // They did not select anything.
          echo 'You did not select anything.';
      } else {
          if ($_POST['name'] == 'tree') {
              // They selected tree..
              echo 'You selected tree.';
          } else {
              // They selected something else.
              echo 'You selected table.';
          }
      }
  }
  
  /*    The Form       */
  
  echo '
<div style="position:absolute; left:45px; top:80px;">
<form action="optiontable.php" name"=optionform" method="post">
<font size="4">View options</font>
<p>Table<input type="radio" name="name" value="table"></p>
<p>Tree  <input type="radio" name="name" value="tree"></p>
<input type="submit" value="Submit">
</div>
';
?>

 

Hope that helps.

 

 

Link to comment
https://forums.phpfreaks.com/topic/60724-tree-structure/#findComment-302093
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.