Combination 'list_item' & 'image_button' PHP/JavaScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • automation
    New Member
    • Sep 2006
    • 2

    Combination 'list_item' & 'image_button' PHP/JavaScript

    I have a web-page consisting of a listbox & image buttons. I want to post to the appropriate PHP script based on which list_item and image button combination is selected, where the logic is determined by JavaScript. So far, I can determine what list_item has been selected, but how do I determine what image button was selected?

    The current PHP Script & JavaScript are below.

    [HTML]<form method="post" action="operati on_request_navi gation.php" name="operation _navigation_for m" onsubmit=
    "return operation()";>
    <div id="Layer17" align="center">
    <table height="89">
    <tr>
    <td align="center">
    <b>
    <font size="2">New Operation</b>
    <select name="operation s_request_type" size="1" align="center">
    <option selected="selec ted" >Select</option>
    <option>Consult ant</option>
    <option>Clien t Account</option>
    </select>

    </td>
    </tr>
    </table>

    </div>
    <div id="Layer18">
    <table width="272" height="150" border="0" cellpadding="0" >
    <tr>
    <td width="89" height="67">&nb sp;</td>
    <td width="177"><in put type="image" class="btn" id="Add" name="process_t ype" value="Add"
    img src="images/Add.gif" alt="Add" width="126" height="37" /></td>
    </tr>
    <tr>
    <td width="89">&nbs p;</td>
    <td width="177"><in put type="image" class="btn" id="View" name="process_t ype" value="View"
    img src="images/View.gif" alt="View" width="126" height="37" /></td></td>
    </td>
    </tr>
    </table>

    <table width="271" height="197" border="0" cellpadding="0" >
    <tr>
    <td width="89">&nbs p;</td>
    <td width="176">
    <a href="./logout_confirma tion.php">
    <img src="images/Logout.gif" alt="Logout" width="126" height="37" border="0"/></td>
    </tr>
    </table>
    </div>
    </form>
    <script>
    function operation() {
    var f = window.document .forms.operatio n_navigation_fo rm.elements[0];
    var g = f.options[0].selected;
    var h = f.options[1].selected;
    var i = f.options[2].selected;
    if(g) {
    alert("Please select an Operation");
    return false;
    }
    if(h) {
    location.href=" ./consulting_sr_f orm.php";
    return true;
    }
    if(i) {
    location.href=" ./operations.php" ;
    return true;
    }
    }
    </script>[/HTML]
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Add on onclick to each button to send the user to the corresponding page.

    Comment

    Working...