sandy1028 Posted July 19, 2007 Share Posted July 19, 2007 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> Quote Link to comment Share on other sites More sharing options...
NArc0t1c Posted July 19, 2007 Share Posted July 19, 2007 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. Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted July 19, 2007 Author Share Posted July 19, 2007 Thanks for the reply... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.