Drawing a Rect2D selection box in reverse

I have a drawing program where I have the ability to draw a Rect2D object onto the screen by clicking and dragging from top/left to bottom/right. It is used for selecting objects that have been drawn. I was wondering how to make it draw in reverse so if you started at the bottom/right and dragged top/left it would also draw a box.
Here is some code:
mouseDragged() {
mdX = e.getX();
mdY = e.getY();
     selectionBox = new Rectangle2D.Float(mmX, mmY, mdX-mmX, mdY-mmY);
     repaint();
mouseMoved() {
mmX=e.getX();
mmY=e.getY();
paint() {
//code to paint selection box
g2.draw(selectionBox)
I tried a bunch of things, and am really stuck on this. Does anyone have any tips on how to do this?

Found the answer:
     int rectX=mmX;
          int rectY=mmY;
          int rectWidth=mdX-mmX;
          int rectHeight=mdY-mmY;
          if(rectWidth<0)     {
               rectX +=rectWidth;
               rectWidth *= -1;
          if(rectHeight<0)     {
               rectY +=rectHeight;
               rectHeight *= -1;
          System.out.println("mmX: "+mmX+" mmY:"+mmY+"mdX: "+mdX+" mdY:"+mdY+" width:"+rectWidth+" height:"+rectHeight);
          selectionBox = new Rectangle2D.Float(rectX,rectY, rectWidth, rectHeight);

Similar Messages

  • Drawing a Selection Box.

    Hello forum,
    Is there an easy way of drawing a selection box or do I have to draw it myself? I have been trying to do it myself but I'm having trouble erasing the previous boxes. All I'm doing is drawing a rectangle, how do I undraw it when the user moves the mouse?
    Selection Box = The user presses the selection tool. When the mouse button is pressed, I start drawing the selection box. As the user moves the mouse, the box gets bigger and smaller.

    found it....what you want to do is use setXORMode.
    public DrawSelectionBox(Rectangle RVRect)
    g2.setXORMode(Color.white);
    g.drawRect(RVRect.x,RVRect.y,RVRect.width,RVRect.height);
    }call this method to draw and erase the rectangle. you can change the color...using white gives you a black box.

  • DYNAMIC SELECT BOX

    The problem is that the second select box is not displaying what is the wrong in the code
    <html>
    <head>
    <script>
    function setList(theList) {
    switch (theList) {
    case 1 : {
    document.theForm.mySelect.options[0].value="50THD-OZAM";
    document.theForm.mySelect.options[1].value="ABABA-BALB";
    document.theForm.mySelect.options[2].value="BALAB-KIDA";
    document.theForm.mySelect.options[3].value="CALIC-BABA";
    document.theForm.mySelect.options[4].value="GUTAO-DINE";
    document.theForm.mySelect.options[5].value="";
    document.theForm.mySelect.options[6].value="";
    document.theForm.mySelect.options[7].value="";
    document.theForm.mySelect.options[0].selected=true;
    document.theForm.radioButton[0].checked=true;
    break;
    case 2 : {
    document.theForm.mySelect.options[0].value="AGON";
    document.theForm.mySelect.options[1].value="AJUY";
    document.theForm.mySelect.options[2].value="Abay";
    document.theForm.radioButton[1].checked=true;
    break;
    case 3 : {
    document.theForm.mySelect.options[0].value="KAL";
    document.theForm.mySelect.options[1].value="ILO ";
    document.theForm.mySelect.options[2].value="LEY";
    document.theForm.radioButton[2].checked=true;
    break;
    setOptionText();
    function setOptionText() {
    document.theForm.mySelect.options[0].text=document.theForm.mySelect.options[0].value;
    document.theForm.mySelect.options[1].text=document.theForm.mySelect.options[1].value;
    document.theForm.mySelect.options[2].text=document.theForm.mySelect.options[2].value;
    var group=new Array(document.theForm.mySelect.options.length)
    for (i=0; i<document.theForm.mySelect.options.length; i++)
    group=new Array()
    group[0][0]=new Option("---Select2---"," ");
    group[1][0]=new Option("Now Select This One"," ");
    group[1][1]=new Option("C","3");
    group[1][2]=new Option("DA","2");
    group[1][3]=new Option("DB","1");
    group[2][0]=new Option("Now Select This One"," ");
    group[2][1]=new Option("A","5");
    function redirect(x)
    var i=document.theForm.mySelect.options.length
    for (m=0;m<i;m++)
    for (i=0;i<group[x].length;i++)
    document.theForm.stage2.options[i]=new Option(group[x][i].text,group[x][i].value)
    </script>
    </head>
    <body onload="setList(1)">
    <form name="theForm" onreset="setList(1)">
    BirthPlace is:<br>
    <input checked name="radioButton" type="radio" value="Brgy" onclick="setList(1)">Brgy&&
    <input name="radioButton" type="radio" value="MuniCity" onclick="setList(2)">Muni/city&&
    <input name="radioButton" type="radio" value="Province" onclick="setList(3)">Province<hr>
    <select name="mySelect" onChange="redirect(this.options.selectedIndex)">
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    </select>
    <select name="stage2" size="1" >
    <option value=" " > </option>
    <option value=" " ></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    <option value=""></option>
    </select>
    <br><br>
    </form>
    </body>
    </html>

    hello mate,
    you can just use another javascript code for your application since it seems that( as well as i understood ) you couldn't set the array if user make a selection.
    A few times ago i had a probelm like that but i used the below code..
    Here the DynamicOptionList.js file and source code:
    you just call this code from your html page like this :
    <SCRIPT LANGUAGE="JavaScript" SRC="DynamicOptionList.js"></SCRIPT>
    //STARTS HERE DynamicOptionList.js
    // CONSTRUCTOR
    // Pass in the name of the element, then the names of the lists it depends on
    function DynamicOptionList() {
         if (arguments.length < 2) { alert("Not enough arguments in DynamicOptionList()"); }
         // Name of the list containing dynamic values
         this.target = arguments[0];
         // Set the lists that this dynamic list depends on
         this.dependencies = new Array();
         for (var i=1; i<arguments.length; i++) {
              this.dependencies[this.dependencies.length] = arguments;
         // The form this list belongs to
         this.form = null;
         // Place-holder for currently-selected values of dependent select lists
         this.dependentValues = new Object();
         // Hold default values to be selected for conditions
         this.defaultValues = new Object();
         // Storage for the dynamic values
         this.options = new Object();
         // Delimiter between dependent values
         this.delimiter = "|";
         // Logest string currently a potential options (for Netscape)
         this.longestString = "";
         // The total number of options that might be displayed, to build dummy options (for Netscape)
         this.numberOfOptions = 0;
         // Method mappings
         this.addOptions      = DynamicOptionList_addOptions;
         this.populate           = DynamicOptionList_populate;
         this.setDelimiter     = DynamicOptionList_setDelimiter;
         this.setDefaultOption      = DynamicOptionList_setDefaultOption;
         this.printOptions      = DynamicOptionList_printOptions;
         this.init           = DynamicOptionList_init;
    // Set the delimiter to something other than | when defining condition values
    function DynamicOptionList_setDelimiter(val) {
         this.delimiter = val;
    // Set the default option to be selected when the list is painted
    function DynamicOptionList_setDefaultOption(condition, val) {
         if (typeof this.defaultValues[condition] == "undefined" || this.defaultValues[condition]==null) {
              this.defaultValues[condition] = new Object();
         for (var i=1; i<arguments.length; i++) {
              this.defaultValues[condition][arguments[i]]=1;
    // Init call to map the form to the object and populate it
    function DynamicOptionList_init(theform) {
         this.form = theform;
         this.populate();
    // Add options to the list.
    // Pass the condition string, then the list of text/value pairs that populate the list     
    function DynamicOptionList_addOptions(dependentValue) {
         if (typeof this.options[dependentValue] != "object") { this.options[dependentValue] = new Array(); }
         for (var i=1; i<arguments.length; i+=2) {
              // Keep track of the longest potential string, to draw the option list
              if (arguments[i].length > this.longestString.length) {
                   this.longestString = arguments[i];
              this.numberOfOptions++;
              this.options[dependentValue][this.options[dependentValue].length] = arguments[i];
              this.options[dependentValue][this.options[dependentValue].length] = arguments[i+1];
    // Print dummy options so Netscape behaves nicely
    function DynamicOptionList_printOptions() {
         // Only need to write out "dummy" options for Netscape
    if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) <= 4)){
              var ret = "";
              for (var i=0; i<this.numberOfOptions; i++) {
                   ret += "<OPTION>";
              ret += "<OPTION>"
              for (var i=0; i<this.longestString.length; i++) {
                   ret += "_";
              document.writeln(ret);
    // Populate the list
    function DynamicOptionList_populate() {
         var theform = this.form;
         var i,j,obj,obj2;
         // Get the current value(s) of all select lists this list depends on
         this.dependentValues = new Object;
         var dependentValuesInitialized = false;
         for (i=0; i<this.dependencies.length;i++) {
              var sel = theform[this.dependencies[i]];
              var selName = sel.name;
              // If this is the first dependent list, just fill in the dependentValues
              if (!dependentValuesInitialized) {
                   dependentValuesInitialized = true;
                   for (j=0; j<sel.options.length; j++) {
                        if (sel.options[j].selected) {
                             this.dependentValues[sel.options[j].value] = true;
              // Otherwise, add new options for every existing option
              else {
                   var tmpList = new Object();
                   var newList = new Object();
                   for (j=0; j<sel.options.length; j++) {
                        if (sel.options[j].selected) {
                             tmpList[sel.options[j].value] = true;
                   for (obj in this.dependentValues) {
                        for (obj2 in tmpList) {
                             newList[obj + this.delimiter + obj2] = true;
                   this.dependentValues = newList;
         var targetSel = theform[this.target];
         // Store the currently-selected values of the target list to maintain them (in case of multiple select lists)
         var targetSelected = new Object();
         for (i=0; i<targetSel.options.length; i++) {
              if (targetSel.options[i].selected) {
                   targetSelected[targetSel.options[i].value] = true;
         targetSel.options.length = 0; // Clear all target options
         for (i in this.dependentValues) {
              if (typeof this.options[i] == "object") {
                   var o = this.options[i];
                   for (j=0; j<o.length; j+=2) {
                        var text = o[j];
                        var val = o[j+1];
                        targetSel.options[targetSel.options.length] = new Option(text, val, false, false);
                        if (typeof this.defaultValues[i] != "undefined" && this.defaultValues[i]!=null) {
                             for (def in this.defaultValues[i]) {
                                  if (def == val) {
                                       targetSelected[val] = true;
         targetSel.selectedIndex=-1;
         // Select the options that were selected before
         for (i=0; i<targetSel.options.length; i++) {
              if (targetSelected[targetSel.options[i].value] != null && targetSelected[targetSel.options[i].value]==true) {
                   targetSel.options[i].selected = true;
    //********** ENDS HERE
    now the html page and how the trick is going :
    <HTML>
    <HEAD>
    <META CONTENT="text/html; charset=windows-1254" HTTP-EQUIV="Content-Type">
    <META CONTENT="text/html; charset=iso-8859-9" HTTP-EQUIV="Content-Type">
         <TITLE>JavaScript Toolbox - Dynamic Option List</TITLE>
    <SCRIPT LANGUAGE="JavaScript" SRC="C:\WINNT\Profiles\calisirmu\Desktop\javaScripts\DynamicOptionList.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    // First example
    var listB = new DynamicOptionList("B","A");
    //first initialize parameters
    listB.addOptions("CARs",
              "BMW","BMW",
              "PEUGEOT","PEUGEOT",
              "PORSCHE","PORSCHE",
              "TOYOTA","TOYOTA");     
    listB.addOptions("MOTORCYCLEs",
              "HONDA","HONDA",
              "KAWASAKI","KAWASAKI");
    listB.addOptions("FORMULA CARS",
              "FERRARI","FERRARI",
              "MERCEDES","MERCEDES",
              "JAGUAR","JAGUAR");
    //set default options
    listB.setDefaultOption("CARs","PORSCHE");
    listB.setDefaultOption("MOTORCYCLEs","HONDA");
    listB.setDefaultOption("FORMULA CARS","FERRARI");
    var listC = new DynamicOptionList("C","A","B");
    listC.addOptions("CARs|PORSCHE","911 TURBO GT2","911 TURBO GT2",
                        "MOBY DICK","MOBY DICK",
                        "GT1 RACE VERSION","GT1 RACE VERSION");
    listC.setDefaultOption("CARs|PORSCHE","911 TURBO GT2");
    listC.addOptions("CARs|BMV","750 IL","750 IL");
    listC.addOptions("CARs|PEUGEOT","406","406");
    listC.addOptions("CARs|TOYOTA","AVENSIS","AVENSIS");
    listC.addOptions("MOTORCYCLEs|HONDA","SUPER 5000","SUPER 5000");
    listC.setDefaultOption("MOTORCYCLEs|HONDA","SUPER 5000");
    listC.addOptions("MOTORCYCLEs|KAWASAKI","SUPER KACAR","SUPER KACAR");
    listC.addOptions("MOTORCYCLEs|KAWASAKI","YAVAS GIDER","YAVAS GIDER");
    listC.addOptions("MOTORCYCLEs|KAWASAKI","ANCA GIDER","ANCA GIDER");
    listC.addOptions("FORMULA CARS|FERRARI","F1 2000","F1 2000");
    listC.setDefaultOption("FORMULA CARS|FERRARI","F1 2000");
    listC.addOptions("FORMULA CARS|MERCEDES","CLK","CLK");
    listC.addOptions("FORMULA CARS|JAGUAR","SALLA GITSIN","SALLA GITSIN");
    function init() {
         var theform = document.forms[0];
         listB.init(theform);
         listC.init(theform);
         listE.init(theform);
         listF.init(theform);
    </SCRIPT>
    </HEAD>
    <BODY BGCOLOR=#FFFFFF LINK="#00615F" VLINK="#00615F" ALINK="#00615F" onLoad="init()">
    <BR><BR>
    <BR>
    <FORM ACTION="" METHOD="" name="Form1">
    <BR>
    <TABLE BORDER="0">
    <TR bgcolor="#ffffe6">
         <TH >TYPE</TH>
         <TH>NAME</TH>
         <TH>MODEL</TH>
    </TR>
    <TR>
         <TD>
              <SELECT NAME="A" onChange="listB.populate();listC.populate();">
                   <OPTION VALUE="CARs">CARs
                   <OPTION VALUE="MOTORCYCLEs">MOTORCYCLEs
                   <OPTION VALUE="FORMULA CARS">FORMULA CARS
              </SELECT>
         </TD>
         <TD>
              <SELECT NAME="B" onChange="listC.populate();">
                   <SCRIPT LANGUAGE="JavaScript">listB.printOptions()</SCRIPT>
              </SELECT>
         </TD>
         <TD>
              <SELECT NAME="C">
                   <SCRIPT LANGUAGE="JavaScript">listC.printOptions()</SCRIPT>
              </SELECT>
         </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>
    you save this html page as xxx.html and thane run it.
    I hope this is beneficial for you.
    mcaldeveloper :-)

  • Selection Box Issues

    Hi folks, this is probably a dumb question but I've looked everywhere online without an answer:
    How can I draw a selection box over 1 or more objects without selecting objects that touch the selection box? - I.e. as an example: in Autocad when you draw a selection box from left to right it only selects what's inside the box, and when you draw it from right to left it selects everything that crosses in and through the selection box... In illustrator I'd like to be able to select only what's inside the box and not what crosses it?
    Apologies if i've confused the issue, I'm a little tired! :-)

    It's not a dumb question, Illustrator just doesn't work that way. You may want to request the feature here.
    "Normal, direct or group" selection tools along with "Shift-clicking" to toggle selections, is the standard approach.
    Also, the Selection Marque tool may help you.
    Finally, effective use of groups, layers and symbols, can greatly simplify selection challenges.

  • How to do it?? in SELECT BOX

    here is the bean class sample code of getting the result set from
    database
    public void setMembers2()
    String query1="select e.idcode from employee e,wb_login w where e.idcode=w.idcode ";
    stmt1=conn1.createStatement();
    rs1=stmt1.executeQuery(query1);
    System.out.println("Executed query");
    if(rs1.next())
    do{
    id=rs1.getString(1);
    System.out.println("THE IDCODE IS JAVA "+id);
    setId_code(id);
    } while(rs1.next());
    else
    System.out.println("THE IDCODES ");
    here is the sample code in jsp i have to populate the Idcode's in SELECT BOX
    <select name="idcode" size="1" >
    <%
    String str1="";
    promotionbn.setMembers2();
    str1=promotionbn.getId_code();
    System.out.println("THE IDCODE IN JSP PAGE IS "+str1);
    %>
    <option value="<%=str1%>"> <%=str1%>
    </select>
    But in the select box priniting only one record.........

    Hey,
    Where are u defining the get/set methods method ??. The code u gave is not very clear. Acording to what u gave below it will surely print only one record probably the last one.
    KM
    here is the bean class sample code of getting the
    result set from
    database
    public void setMembers2()
    String query1="select e.idcode from employee
    e,wb_login w where e.idcode=w.idcode ";
    stmt1=conn1.createStatement();
    rs1=stmt1.executeQuery(query1);
    System.out.println("Executed query");
    if(rs1.next())
    do{
    id=rs1.getString(1);
    System.out.println("THE IDCODE IS JAVA
    CODE IS JAVA "+id);
    setId_code(id);
    } while(rs1.next());
    else
    System.out.println("THE IDCODES ");
    here is the sample code in jsp i have to populate the
    Idcode's in SELECT BOX
    <select name="idcode" size="1" >
    <%
    String str1="";
    promotionbn.setMembers2();
    str1=promotionbn.getId_code();
    System.out.println("THE IDCODE IN JSP PAGE IS
    "+str1);
    %>
    <option value="<%=str1%>"> <%=str1%>
    </select>
    But in the select box priniting only one
    record.........

  • The html select box option is not getting displayed properly in IE11

    The html select box option is not getting displayed properly in IE11
    I have developed a website that has a select box drop down. The select box drop down is getting displayed properly in IE9. But in IE11, if I am selecting any option apart from the first one, the whole select box option is getting moved up in the page.
    In IE11, if option 2 is selected, then the select options is getting moved up. But in IE9, if option 2 is selected, then the select options is getting displayed properly.
    Please let me know the fix so that the select options are displayed in the same manner as in IE9.
    Sorry but I am unable to upload images as this site is throwing some error

    Hi Kevin Shen,
    Thanks for post.
    I tried above code in ie 11(version 11.0.9600.17633).
    But it is not working. If you select option 2, and open select box then it open on the select box.
    It should open below the select box.
    Code for above:-
    <select>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    </select>
    Sorry I could not attach screen shot. We have normal select box with three options. If we select option 2, it is showing option list on the select box. It is coming below the select box in ie 10 and other browse like chrome. 
    So what we should do, so that all options will come below the select box?
    Thanks,
    Yogesh Toke

  • Multi-Select Box Not Displaying Values Passed From Grid?

    Coldfusion 8
    I inherited an application and am trying to maintain and improve it... hit a snag today.
    I have a multi-select box that is not displaying what I expect.  The values come from a ColdFusion grid which is based off a database query.
    Here is the code for the select - does not work - nothing is selected:
    <cfselect name="USER_IDS" multiple="true" queryposition="below" selected="USER_IDS" query="ActiveUsersPlus" disabled="#disabled#" value="G_USER_WORK_UNIT_SK" display="G_USER_ID" >
    </cfselect>
    Now if I change the multiselect to a single select like below - it takes the first item in the field list (from the grid) and selects it in the drop down.
    <cfselect name="USER_IDS" multiple="false" queryposition="below" selected="USER_IDS" query="ActiveUsersPlus" disabled="#disabled#" value="G_USER_WORK_UNIT_SK" display="G_USER_ID" >
    </cfselect>
    Or if I assign a variable like this and use the multi-select code it seems to work as well.
    testlist = "22,26";
    <cfselect name="USER_IDS" multiple="true" queryposition="below" selected="#testlist#" query="ActiveUsersPlus" disabled="#disabled#" value="G_USER_WORK_UNIT_SK" display="G_USER_ID" >
    </cfselect>
    I have displayed the value of "User_IDs" in the grid and in the data entry part of the screen to see values of:  22,26
    to make sure that wasn't my issue.
    Do grids and multiselects require something additional?  Any advice on how to resolve?

    Problem was related to some javascript for the select box.  There was a function for a single select box but not a multiple select box - this fixed it: 
    if(theForm.elements[i].type == "select-multiple"){
                        var selectBox = theForm.elements[i];
                        var sbname = selectBox.name;
                        cpvalue = String(eval('record.data.' + sbname));
                        var NotifyArray = cpvalue.split(',');
                        for (var j=0; j < selectBox.length; j++) {
                            selectBox[j].selected = false;
                        for (var j=0; j < selectBox.length; j++) {
                            sbvalue = selectBox[j].value;
                            for (var k=0; k < NotifyArray.length; k++){
                                if (sbvalue == NotifyArray[k]){
                                    selectBox[j].selected = true;

  • Building a select box multiple times on one page.

    Hello,
    I have a ResultSet rsAgencies that contains all of the information needed to create the options for the agencies select box. It works something like this:
    <select name="selAgencyId" id="selAgencyId" class="Standard">
         <option value="-1" selected>Select One</option>
         <% while (rsAgencies.next()){ %>
              <option value="<%= rsAgencies.getInt("id") %>"><%= rsAgencies.getString("name") %></option>
         <%}%>
    </select>Pretty straight forward. But I need to print these same options out in several different select boxes on the same page and can't figure out how to encapulate this functionality in order to do it.
    In ASP, I would have simply had a function declared on this page that I would pass the ResultSet to. It would loop through the rs and build the options.
    But JSP won't let me declare a function (or maybe I just don't have the syntax right).
    I have also tried putting it in a bean and calling that function from the JSP, but it kindof skips over it for some reason.
    If anyone has done this and can give me a nudge toward the best practice, I would be forever grateful.
    Thanks
    James.

    Limey,
    Thanks. I did not know that about the declaration tags.
    Yes, I decided to build a function that accepts a resultset and returns a vector. It allows me to minimize trips to the database as well as loop through multiple times.
    I ended up putting that function in a bean that will hold all of my common functions for the application. I assume that is a pretty fairly standard way of sharing functionality from page to page.
    Thanks again.
    James.

  • How can I see the numbers of lines selected in a Multiple Selection Box?

    Hi everybody,
    what I want to do is to get in an array of numbers all the lines selected.
    For instance, if I select the rows 1,4 and 7 from a Multiple Selection Box
    of 10 rows in total, how can I see that array when the rows 1,4 and 7 are
    selected?
    Because I want to connect this numbers to Case Structure and if the only
    rows selected are 1,4 and 7, the Case Structure will only realize this cases,
    and the rest will be ignored.
    I'm sure there is some way to get what I want.
    Thank you for your helpful.

    THANK YOU VERY MUCH. IT WORKS PERFECTLY!!!
    "Dennis Knutson" wrote:
    >>If you just wire the list box to an array indicator, you will see that
    the>output is an array of the selected items. Auto index the array through
    a>for loop that has your case statement inside.>>Dennis Knutson>>"Carlos
    Jorge" wrote>>Hi everybody,>>what I want to do is to
    get in an array of numbers all the>lines selected.>For instance, if I select
    the rows 1,4 and 7 from a Multiple>Selection Box>of 10 rows in total, how
    can I see that array when the rows>1,4 and 7 are>selected?>>Because I want
    to connect this numbers to Case Structure>and if the only>rows selected are
    1,4 and 7, the Case Structure will only>realize this cases,>and
    the rest
    will be ignored.>>I'm sure there is some>way to get what I want.>>Thank you
    for your helpful.>>

  • Change the default option for a select box

    Hi,
    I have a select box, with the options built from a Spry Dataset
    <select name="AvatarSelect" id="AvatarSelect" spry:region="myAvatars">
        <option spry:repeat="myAvatars">{A_NAME}</option>
      </select>
    I wish to change the default selected option (which is usually the first row returned from the dataset) based on a value for A_NAME that I know from another spry dataset.
    Tried using Spry.$$('#AvatarSelect') to get to the the array of select options but to no avail.
    How can I cycle through the options and then set the selected on, based on a match for A_NAME?
    Cheers
    Phil

    Hi Phil
    I think this is the way
    <select name="AvatarSelect" id="AvatarSelect" spry:region="myAvatarsLookup myAvatarsValue">
      <option spry:repeat="myAvatarsLookup" spry:test="'{myAvatarsValue::A_NAME}'=='{myAvatarsLookup::id}'" value="{myAvatarsLookup::id}" selected="selected">{A_NAME}</option>
      <option spry:repeat="myAvatarsLookup" spry:test="'{myAvatarsValue::A_NAME}'!='{myAvatarsLookup::id}'" value="{myAvatarsLookup::id}">{A_NAME}</option>
    </select>
    Cheers

  • Dynamic populating the items in the select boxes

    Hi,
    I need three select boxes on a webpage in such a way that the options in select box 2 should be populated only after selecting some item in "select box 1" and the options in the "select box 3" should be displayed by selecting the options in "the select box2". The data is being retrived from the database. I know that this functionality can be acheived through the "javascript". I am fine until getting the data from the database but not sure how to get it work using javascript.
    I would appreciate if someone can post any snippet of code or give any suggesstions or pointer on how to proceed....
    -coolers

    probably should ask on a javascript forum then. This is for java.

  • How to populate optional items in SELECT BOX

    // REGISTRATION.JSP//
    <%@ page import="java.util.Enumeration" %>
    <%@ page import="java.util.Vector" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="beans.register2" %>
    <jsp:useBean id="registerbn" scope= "session" class="beans.register2" />
    <% String base = (String) session.getAttribute("base");
    registerbn.setDburl((String)session.getAttribute("dbUrl"));
    registerbn.setDbuser((String)session.getAttribute("dbUserName"));
    registerbn.setDbpasswd((String)session.getAttribute("dbPassword"));
    System.out.println("Inside jsp - setMembers of promotion successful");
    registerbn.setMembers();
    System.out.println("after setting");
    %>
    <%
    String action=request.getParameter("action");
    %>
    <HTML>
    <HEAD>
    <TITLE> TIFR INTRANET </TITLE>
    </HEAD>
    <HEAD>
    <script language="_JavaScript1.2">
    function isIdcode()
    / validating
    function isUser()
    / validating
    function isEmail()
    / validating
    function isPassword()
    / validating
    function isDob()
    / validating
    </javascript> -----java script ends here----------------
    <TD align="top" valign="top"><jsp:include page="menu.jsp" flush="true"/>
    </td>
    <td>
    <table cellpadding="2" cellspacing="3" width="40%">
    <form method="post" action="./beans.register2">
    Fisrt question: we have creaated "register2.java "as beans class for setting the values in to the data base.
    is it correct ?
    <td width="40" align="center"
    <font face="arial" size="5" align="right">
    <b>
    Registration <hr> </hr>
    </b>
    </font>
    <br>
    </td>
    <tr valign="center" width="80%">
    <td width="40%">
    <b><font face="Arial" size="2">IdCode </b> </font>
    </td>
    <td width="40%">
    <b><font face="Arial" size="2">
    <input type="text" name="idcode" size="6" style="border-style:solid" value="">
    </font></b>
    </td>
    </tr>
    <tr width="80%">
    <td width="40%">
    <b><font face="Arial" size="2">User </font></B></td>
    <td width="40%">
    <input type="text" name="user" size="12" style="border-style: solid" value="">
    </font></b></td>
    </tr>
    <tr width="80%">
    <td width="40%">
    <b><font face="Arial" size="2">Password </font></B></td>
    <td width="40%">
    <input type="password" name="password" size="25" tabindex="20" style="border-style: solid" width="12" value="">
    </font></b></td>
    </tr>
    <tr width="80%">
    <td width="40%">
    <b><font face="Arial" size="2">Section code </font></b></td>
    <td width="40%">
    <select size="1" name="section_code" tabindex="9"
    style="border-style: solid">
    <%@ include file="section.txt" %>
    Secound question:
    // inclided simple .txt file here
    // what if new item get enlisted in the database , we have to countinuesly update this .txt file ? so we head for creating simple beans class for retriving values
    then displaying in the SELECT box
    // we dont know how to do it.
    //other html tags //
    ----------------at end -----------------
    <input type="Submit" value="Submit" name="B1" > </td>
    <td width="40%">
    <input type="reset" value="Reset" name="B2"></td>
    <%
    String action=request.getParameter("Submit");
    if(action!=null && action.equals("Submit"))
    try{
    String idcode=request.getParameter("idcode");
    String user=request.getParameter("user");
    String password=request.getParameter("password");
    String seccode=request.getParameter("section_code");
    String Category=request.getParameter("Category");
    String BCategory=request.getParameter("BCategory");
    String Bheads=request.getParameter("Bheads");
    String OtherCategory=request.getParameter("OtherCategory");
    String email=request.getParameter("email");
    String day=request.getParameter("day");
    String month=request.getParameter("month");
    String year=request.getParameter("year");
    String Dob=day+"/"+month+"/"+year;
    String day1=request.getParameter("day1");
    String month1=request.getParameter("month1");
    String year1=request.getParameter("year1");
    String Doj=day1+"/"+month1+"/"+year1;
    registerbn.setIdcode("idcode");
    registerbn.setUser("user");
    registerbn.setPassword("password");
    registerbn.setSec_code("seccode");
    registerbn.setCategory("Category");
    registerbn.setBut_Category("BCategory");
    registerbn.setBut_heada("Bheads");
    registerbn.setOther_Category("OtherCategory");
    registerbn.setemail("email");
    registerbn.setDob("Dob");
    registerbn.setDoj("Doj");
    registerbn.saveData();
    /// saveData() is the one method where we are wrintn query to insert in to database//
    }catch(Exception ex)
    out.println("ERROR :has occured ");
    %>
    </table>
    </table>
    </table>
    </form>
    </td>
    </tr>
    <jsp include page="Footer.jsp" flush="true"/>

    To do that you have to get your recordset, and insert option tags into a while cicle. Something like this:
    <select name="mySelectName">
    <%while(myRecordSet.next()){%>
    <option value="<%=myRecordset.getObject(myField1)>"><%=myRecordset.getObject(myField2)%></option>
    <%}%>
    </select>

  • How to Populate values dynamically in Select Box.

    Hi All,
    I have few select boxes in my webdynpro application. Right now I am populating them using Harcoded values in the Dictionary. But I dont want to harcode the values in the dictionary, i want pull the values from database tables or  text files of EP KM. Just let me know which is the better way to populate the select box without hardcoding & why ?
    Thanks in Advance.
    Regards,
    Aditya Metukul

    Hi Aditya,
    Getting values from KM and database is possible
    It depends on your requirement
    ie if the dropdown should contain details of documents from KM or it should display the details in a table
    if it is oracle table see this link
    Webdynpro and Oracle
    if you want to get data from km see this tutorial
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/tutorial on using knowledge management functions in web dynpro - 26.htm
    Hope this helps you
    Regards
    Rohit
    Regards
    Rohit

  • How to populate select boxes in custom work flows?

    We are trying to create a workflow that allows users to select a few item details from a select box inside the form. I created the select box but I can't figure out how to populate it with elements. I've been reluctant to post here because this question seems so straight forward but I haven't been able to find the answer and don't want waste more time searching for this answer. Please help!
    Thanks,
    Richard

    Sorry for the trouble, I found the answer. I was looking in all the wrong places. Thanks anyway!
    Richard

  • Add form fields dynamically onchange of a select box.

    I have a JSP page with a <h:form>:
    <h:form id="registrationForm">
         <h:outputText value="#{Resource.EmailAddress}" /><br />
         <h:inputText label="E-mail Address" id="emailAddress" value="#{RegistrationBean.emailAddress}" required="true" requiredMessage="#{Resource.RequiredError}">
              <f:validator validatorId="EmailValidator" />
         </h:inputText><br />
         <h:message for="emailAddress" styleClass="error" /></td>
         Select age range<br />
         <h:selectOneMenu id="ageRange" value="#{RegistrationBean.ageRange}" valueChangeListener="#{RegistrationBean.updateComponents}" onchange="javascript: return submit()">
              <f:selectItems value="#{RegistrationBean.ageRangeValues}" />
         </h:selectOneMenu><br />
         <h:commandButton id="submit" value="#{Resource.Submit}" />
    </h:form>When the user changes the value for the ageRange select box, the form gets submitted through the following JavaScript:
    function submit() {
         document.forms[0].submit();
         return true;
    }Then the ValueChangeListener defined in a backing bean for the ageRange select box gets called:
    public void updateComponents(ValueChangeEvent e) {
         // Generate components automatically
    }What I want is, when the user changes the value of the ageRange select box, the valueChangeListener should generate a few new text fields in the form and the validator for the e-mail address field shouldn't get called. The validator for the email-address field should only get called once the user clicks on the Submit button.
    Any help or pointers will be greatly appreciated.

    You can find here lot of pointers: http://balusc.blogspot.com/2007/10/populate-child-menus.html

Maybe you are looking for

  • No object type found for the corresponding message in BPM

    Hi All, I have a BPM scenario where i pick a file and based on a condition in the Switch i send the meesage to Mail or Proxy. When i tested the scenario i got error as "no object type found for the message check the corresponding process activated" e

  • Why do photos I moved offline in PSE11 not have a preview file available?

    I moved photos offline in PSE11 and now the photos all have a "missing" icon rather than an "offline" icon.  If I try to use them in a slideshow it says they are missing.  I know I can connect the hard drive they are on, but I used to be able to do t

  • Vendor enterprise services

    Hello, I'm looking for an entreprise service which returns the basic data or complete data of one or several customer/s in ERP(i.e. I need the information of customer with ID = 0000000025) or i.e. I need all data of all my customers, ID = *). I found

  • Purchase requisitions for  raw materials

    Iam having multilevel BOM and when I do Sales order MRP then Iam getting planned order for Semi finished items but not getting Purchase requisitions for  raw materials.

  • Looking for Recommendation for Redundant or Backup ISP configuration: ASA 5510

    Good Day, Currently I have two ASA 5510's version 8.2(5) with the security plus license in my environment. These are configured to failover with the SAME ISP in the event of hardware failure. We are currently trying to introduce ISP backup configurat