Two select box in a form in JSP...Save me...Please

Hi,
My jsp page has one form with two different select/option. One select is fbox and another is tbox. tbox contains master values from db and fbox contanis some/few/no values from db.(It might be empty.) Now, I want to add a value from tbox to fbox. If that value is already in fbox then ALERT otherwise add in that value in fbox. Following is the code for that.
Would somebody help me out ? I don't know what's wrong with this code. It's not working............It's kind of serious and urgent.
function add(fbox,tbox) {
var i = 0;
if(fbox.value != "") {
var no = new Option();
for(var i=0; i < tbox.options.length; i++)
if((fbox.value == tbox.options.value) || (fbox.value == tbox.options[i].text))
alert("Value is already added. Select another item.");
break;
else
no.value = fbox.value;
no.text = fbox.value;
tbox.options[tbox.options.length] = no;
fbox.value = "";
else
alert("Please enter an item.");

Hi Srinath or anybody,
Would u pl. tell me what's wrong with following code ? Javascript prompt is not invoking....U can see/find javascript function addservice(service) in my code which is called by JSP code inside in my form...
I am using Tomcat 3.3, Jdeveloper 3.2, IE 6.0 and Netscape 7.0.
I am badly working on this but Javascript prompt is not working....
Thanks for ur time and help...
Waiting for ur reply.
David
<%@ page contentType="text/html;charset=WINDOWS-1252"%>
<%@page language= "java" import= "java.sql.*,sun.jdbc.rowset.*,javax.servlet.http.*,java.lang.reflect.*,java.io.*,java.util.*,javax.servlet.*"
errorPage="error.jsp" %>
<jsp:useBean id="conn" class="package1.connectionBean" scope="session"/>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=WINDOWS-1252">
<META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
</HEAD><center>
<BODY>
<script language="javascript" SRC="FormChek.js"></script>
<script language="javascript">
function CheckFstock(ftock) {
var Gooddigit = "0123456789";
     if (document.formtest.ftock.value.length > 3 )
          alert('Invalid Stock ! Please re-enter with less than equal to 3 digits.');
          return false;
     }// if ends
function CheckPostal(postal) {
     var valid = 1;
     var GoodChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     var Gooddigit = "0123456789";
     var Goodextrs = "- ";
     var i = 0;
     if (document.formtest.postal.value == "")
          // Return false if number is empty or length is not 7 length is not 6
          alert('Invalid Postal Code ! Please re-enter now.');
          valid = 0;
document.formtest.postal.focus();
          return false;
     }//if ends
     else if(document.formtest.postal.value.length == 7)
          //alert (GoodChars.indexOf(document.formtest.postal.value.charAt(0)));
          for (i =0; i <= document.formtest.postal.value.length; i++)
               //alert( i + "->"+ document.formtest.postal.value.charAt(0))
               if ((GoodChars.indexOf(document.formtest.postal.value.charAt(0)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(2)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(5)) == -1))
                    alert("Not Valid Chacters in entered Postal Code! Please re-enter now.");
                    valid = 0;
document.formtest.postal.focus();
                    return false;
               } // if ends
               if ((Gooddigit.indexOf(document.formtest.postal.value.charAt(1)) == -1) || (Gooddigit.indexOf(document.formtest.postal.value.charAt(4)) == -1) || (Gooddigit.indexOf(document.formtest.postal.value.charAt(6)) == -1))
                    alert("Not Valid digits in entered Postal Code! Please re-enter now.");
                    valid = 0;
document.formtest.postal.focus();
                    return false;
               } // if ends
               if (Goodextrs.indexOf(document.formtest.postal.value.charAt(3)) == -1)
                    alert("Not Valid extras in entered Postal Code! Please re-enter now.");
                    valid = 0;
document.formtest.postal.focus();
                    return false;
               } // if ends
          } // for ends
     }// else if ends
     else if(document.formtest.postal.value.length == 6)
          for (i =0; i <= document.formtest.postal.value.length; i++)
               if ((GoodChars.indexOf(document.formtest.postal.value.charAt(0)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(2)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(4)) == -1))
                    alert("Not Valid Chacters in entered Postal Code! Please re-enter now.");
                    valid = 0;
document.formtest.postal.focus();
                    return false;
               } // if ends
               if ((Gooddigit.indexOf(document.formtest.postal.value.charAt(1)) == -1) && (Gooddigit.indexOf(document.formtest.postal.value.charAt(3)) == -1) && (Gooddigit.indexOf(document.formtest.postal.value.charAt(5)) == -1))
                    alert("Not Valid digits in entered Postal Code! Please re-enter now.");
                    valid = 0;
document.formtest.postal.focus();
                    return false;
               } // if ends
          } // for ends
     }// else if ends
     else { alert('Postalcode is not 7 or 6 charactres long ! Please  re-enter now.');
document.formtest.postal.focus();
}//else ends
     return valid
}//this function ends
function goback() {
history.go(-1);
function addItem(fbox,tbox)
var boxLength = tbox.length;
var selectedItem = document.formtest.list1.selectedIndex;
var selectedText = fbox.options[selectedItem].text;
var selectedValue =fbox.options[selectedItem].value;
var j;
var isNew = true;
//alert('BOx Length is : ' + boxLength);
if (boxLength != 0)
for (j = 0; j < boxLength; j++)
thisitem = tbox.options[j].text;
if (thisitem == selectedText)
isNew = false;
alert("Selected value is already available. Please select a different item");
break;
if (isNew)
newoption = new Option(selectedText, selectedValue, false, false);
tbox.options[boxLength] = newoption;
fbox.selectedIndex=-1;
function remove(box) {
if (confirm("Are you sure you want to delete. Continue?")) {
for(var i=0; i<box.options.length; i++) {
if(box.options.selected && box.options[i] != "") {
box.options[i].value = "";
box.options[i].text = "";
BumpUp(box);
function BumpUp(abox) {
for(var i = 0; i < abox.options.length; i++) {
if(abox.options[i].value == "") {
for(var j = i; j < abox.options.length - 1; j++) {
abox.options[j].value = abox.options[j + 1].value;
abox.options[j].text = abox.options[j + 1].text;
var ln = i;
break;
if(ln < abox.options.length) {
abox.options.length -= 1;
BumpUp(abox);
function Moveup(dbox) {
for(var i = 0; i < dbox.options.length; i++) {
if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0]) {
var tmpval = dbox.options[i].value;
var tmpval2 = dbox.options[i].text;
dbox.options[i].value = dbox.options[i - 1].value;
dbox.options[i].text = dbox.options[i - 1].text
dbox.options[i-1].value = tmpval;
dbox.options[i-1].text = tmpval2;
function Movedown(ebox) {
for(var i = 0; i < ebox.options.length; i++) {
if (ebox.options[i].selected && ebox.options[i] != "" && ebox.options[i+1] != ebox.options[ebox.options.length]) {
var tmpval = ebox.options[i].value;
var tmpval2 = ebox.options[i].text;
ebox.options[i].value = ebox.options[i+1].value;
ebox.options[i].text = ebox.options[i+1].text
ebox.options[i+1].value = tmpval;
ebox.options[i+1].text = tmpval2;
function dosubmit() {
for ( var i = 0; i < document.formtest.list2.length; i++ )
document.formtest.list2.item(i).selected = true;
for ( var i = 0; i < document.formtest.service.length; i++ )
document.formtest.service.item(i).selected = true;
function addservice(service) {
var defaultSelected = true;
var selected = true;
//alert('Here');
var input_box = prompt("Enter some text","");
//alert(input_box);
if(input_box != "")
var optionName = new Option(input_box,input_box,false,false);
var length = service.length;
service.options[length] = optionName;
else
alert("Service should not be empty ! Write Something.");
</script>
<form name="formtest" METHOD="POST" onSubmit="dosubmit()">
<% String sql;
sql = "SELECT LINEID, DESCRIP from PURCHVENDOR.AUTOLINE";
ResultSet results = conn.executeQuery(sql);
%>
<TABLE BORDER="1">
<TR>
<TD>Code/Type</TD>
<TD><INPUT TYPE="TEXT" NAME="vcode" SIZE="38">
<select name="tp">
<option value="S">Standard</option>
<option value="A">Aftermarket</option>
</select>
</TD>
</TR>
<TR>
<TD>Vendor Name</TD>
<TD><INPUT TYPE="TEXT" name="vname" SIZE="54"></TD>
</TR>
<TR>
<TD>Contact Name</TD>
<TD><INPUT TYPE="TEXT" name="cname" SIZE="54"></TD>
</TR>
<TR>
<TD>Address</TD>
<TD><INPUT TYPE="TEXT" name="address" SIZE="54"></TD>
</TR>
<TR>
<TD>P.O.Box</TD>
<TD><INPUT TYPE="TEXT" name="POBox" SIZE="54"></TD>
</TR>
<TR>
<TD>City</TD>
<TD><INPUT TYPE="TEXT" name="city" SIZE="54"></TD>
</TR>
<TR>
<TD>Province/Postal</TD>
<TD>
<INPUT TYPE="TEXT" name="province" SIZE="25" onChange="checkStateCode(this)">
<INPUT TYPE="TEXT" name="postal" SIZE="25" onChange="CheckPostal(this)"></TD>
</TR>
<TR>
<TD>Phone Number</TD>
<TD><INPUT TYPE="TEXT" NAME="pnumber" SIZE="54" onChange="checkUSPhone(this)"></TD>
</TR>
<TR>
<TD>Fax Number</TD>
<TD><INPUT TYPE="TEXT" name="fnumber" SIZE="54" onChange="checkUSPhone(this)"></TD>
</TR>
<TR>
<TD>Fee Stock/Factory</TD>
<TD><INPUT TYPE="TEXT" name="ftock" SIZE="25">
<INPUT TYPE="TEXT" name="ffactory" SIZE="25">
</TD>
</TR>
<TR>
<TD>Prefered Vendor</TD>
<TD><input type="radio" value="1" name="choice" Checked>Yes
<input type="radio" value="2" name="choice">No
</TD>
</TR>
<TR>
<TD>Line Carried</TD>
<TD><select multiple size="5" name="list1" >
<%
while(results.next())
%>
<OPTION value = "<%= results.getString("lineid")%>"><%= results.getString("lineid")%></OPTION>
<%
%>
</select>
<input type=button value="Add" onclick = "javascript:addItem(this.form.list1,this.form.list2);"</input>
<select multiple size="5" name="list2"></select>
<input type=button value="Delete" onclick = "javascript:remove(this.form.list2);"</input>
</TD>
</TR>
<TR>
<TD>Service</TD>
<TD>
<select multiple size="5" name="service"></select>
<input type=button value="Add Service" onclick = "addservice(formtest.service);"</input>
<input type=button value="Delete Service" onclick = "javascript:remove(this.form.service);"</input>
</TD>
</TR>
</TABLE>
<P><INPUT TYPE="SUBMIT" VALUE="Add" onClick="document.formtest.action='addvpdb.jsp';"</input>
<INPUT TYPE="SUBMIT" VALUE="Cancel" onClick="document.formtest.action='vendormain.jsp';"</input>
<!-- <INPUT TYPE="SUBMIT" VALUE="Cancel" onClick= "goback()"</input> -->
</P>
</center>
</form>
</BODY>
</HTML>

Similar Messages

  • Multiple Select boxes in one form

    Does anyone know if it is possible to have multiple select
    boxes inside one form? I have six different select boxes that are
    generated by six separate queries. The action page for all six
    select boxes is the same so I just want one submit button so users
    don't get confuse. I don't want to cluster up the page with submit
    buttons but I may resort to that option.
    My problem is the select boxes generate a number and when
    that number is submitted I want to pass two other variables with it
    to the action page. I tried putting a "Form" tag around the 6
    select boxes. Inside each select box I tried to add an "Input
    type="hidden"" and give thte name and values that I needed. That
    worked for the first select box but when I tried the second select
    box it used the hidden values for the first select box.
    If anyone can help, I would greatly appreciate it. Or if you
    have any other suggestions I am open to any.
    Thanks

    Paross1,
    I wasn't thinking about that and you gave me a great idea.
    Here is how I changed my select boxes.
    <cfform
    action="Resolution_History.cfm?year=#year#&sessiontype=#sessiontype#&btype=res"
    name="form">
    <select name="SRINPUT">
    <option value="">SR
    <CFOUTPUT Query="findSR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="HRINPUT">
    <option value="">HR
    <CFOUTPUT Query="findHR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="SCRINPUT">
    <option value="">SCR
    <CFOUTPUT Query="findSCR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <br>
    <select name="HCRINPUT">
    <option value="">HCR
    <CFOUTPUT Query="findHCR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="SJRINPUT">
    <option value="">SJR
    <CFOUTPUT Query="findSJR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="HJRINPUT">
    <option value="">HJR
    <CFOUTPUT Query="findHJR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <INPUT TYPE="Submit" VALUE="Submit" alt="submit
    button">
    </cfform>
    On the action page I need the below IF statement to work so
    it will set the variables. It isn't working at this time. Its not
    bringing the values of billnumber, houseorig or the billtype.
    Do you have any thoughts? I know it is close. I need to set
    all of the inputs to input4 to generate my queries.
    <cfif form.srinput gt 0>
    <cfset houseorig eq "s">
    <cfset billtype eq "r">
    <cfset srinput eq input4>
    <cfelseif form.hrinput gt 0>
    <cfset houseorig eq "h">
    <cfset billtype eq "r">
    <cfset hrinput eq input4>
    <cfelseif form.scrinput gt 0>
    <cfset houseorig eq "sc">
    <cfset billtype eq "r">
    <cfset scrinput eq input4>
    <cfelseif form.hcrinput gt 0>
    <cfset houseorig eq "hc">
    <cfset billtype eq "r">
    <cfset hcrinput eq input4>
    <cfelseif form.sjrinput gt 0>
    <cfset houseorig eq "sj">
    <cfset billtype eq "r">
    <cfset sjrinput eq input4>
    <cfelse>
    <cfset houseorig eq "hj">
    <cfset billtype eq "r">
    <cfset hjrinput eq input4>
    </cfif>

  • Two select lists in tabular form

    I have two Select Lists which one of them depends on the another -the second one's query depends on the first one's - .....
    This operation can be done in a form or a page, but how it could be done in a tabular form???
    Saad

    The simple answer is that to the best of my knowledge, it cannot be done because of how the tabular form works. If I understand it correctly, Tabular forms are populated completely at page load and cannot post back from items inside the form in order to refresh a list of values on the second select list. If you want to do this, you will need to build the form as a "Form and Report" page type where you have links in your report that populate a regular page form. Just tell it to put the form and the report on the same page them add a hidden page item that you set to 1 or 0 to display the form and setup the form processing so it is button tied instead of unconditional (You may have to duplicate auto processing processes).
    The complex answer....there probably is a way to do this using AJAX as AJAX is good at this kind of stuff and every field in the tabular form has an HTML id of some kind....but I am not well versed enough in AJAX to give you a straight answer as to how to accomplish it. I used AJAX to do something similar to what your talking about but it was with regular page items (using a select list to populate a shuttle without a post back) and not items in a tabular form.

  • How can i fill selection box on html form with data on the clientside?

    hi
    i want to make a html form that reads option values from the client.
    Because there are too many data, it's not reasonable for me to design a page which connects to server each time to fill the selection boxes.Instead i want to check if data resides at the clientside, if so fill selection boxes with that data, if not download it for the first time and store it on the client for later local retrieval.In addition i must be able to update that data residing on the client when i want.

    Don't see where Java comes into this. Sounds like you'd be using JavaScript on the client.
    A cookie would probably be the only way to save data on the client.

  • Help turn two select boxes into three...

    I am looking to take this code (or variation thereof) and turn the two drop downs into three.
    1. Select One
    populates
    2. Select two
    populates
    3. Select three
    each will have its own set of var(s) and will populate per the previous. the code i have comes from a guy that is no longer employed with us and we have no one right now...so I am looking for a little bit of help here...
    with these being 'selections' they will then go from the boxes and be transmitted to my crm via web form...all http post...
    here is what i have so far:
    <script>
    function dropDownChanged(dd)
         if(eval('typeof(' + dd.name.replace(/:/g, "_") + '_children) == \'undefined\'')) return;
         var thisDd;
         if(document.all)
              thisDd = document.all[eval(dd.name.replace(/:/g, "_") + '_childcontrol')];
         else
              thisDd = document.getElementById(eval(dd.name.replace(/:/g, "_") + '_childcontrol'));
         thisDd.options.length = 0;
         var childElements = eval(dd.name.replace(/:/g, "_") + '_children');
         for(var c=0 ; c < childElements.length ; c+=2)
              if(childElements[c] == dd.value)
                   for(var o=0 ; o < childElements[c+1].length ; o+=2)
                        thisDd.options[o/2] = new Option(childElements[c+1][o], childElements[c+1][o+1]);
         dropDownChanged(thisDd);
    </script>
    <script>var ap_childcontrol = 'opp1';
    var ap_children = ['no',['------------Select an here first--------------------','no'],'Selection 1',['option 1','option 1'],'Selection 2',['option 1','option 1'],'Selection 3',['option 1','option 1'],'Selection 4',['option 1','option 1','option 2','option 2','option 3','option 3'],'Selection 5',['option 1','option 1'],'Selection 6',['option 1','option 1']];
    </script>if anyone can assist me here, i would be in great appreciation...
    thanks in advance!
    ray

    rflores88 wrote:
    looking for the right thread, can you help?I can't since I don't do JavaScript, but my friend Google can. Simply Google for a JavaScript forum. Good luck.

  • Popup selection box in Designer form

    I'm new to Adobe Designer (we're using v7.0) and have a question. I've
    designed an Adobe e-form that has a CLASSIFICATION text field area.
    When the user clicks the CHANGE button I want a window to popup that
    presents a lists of classifications the user can choose from and when
    they confirm the CLASSIFICATION text field will be updated. I know how
    to do this in HTML but is this same thing possible in an Adobe e-form.
    The e-form will be distributed via e-mail and saved locally. Then the
    user will edit the e-form using Adobe Acrobat. I'm mentioning this
    because, from what I've read about Designer, that might make a
    difference. I'm using Javascript for the object event callbacks.

    It's possible, but this is some pretty advanced stuff. Take a look at the Dialog class in the Acrobat JavaScript Reference. There's some sample script starting at page 102 too.
    Chris
    Adobe Enterprise Developer Support

  • 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

  • Autosuggest and select box

    I was wondering how to update a select box with data relevant
    to a selection made on a suggest box, something similar to
    this,
    but with a spry suggest box instead of the first select box on the
    example.
    I tried the example (two select boxes using two binded data
    sets) with my db and it works; when I select something on the first
    select box, the second one changes dynamically according to the
    selection made.
    I have defined two datasets:
    var ds1 = new
    Spry.Data.XMLDataSet("API/make_entry_list_xml.php","viperdb/entry",{sortOnLoad:"pdb_id",s ortOrderOnLoad:"ascending"});
    var ds2 = new
    Spry.Data.XMLDataSet("API/get_chains_for_entry_id.php?VDB={ds1::pdb_id}","viperdb/entry/c hain_id");
    and defined the suggest and select boxes as:
    <div id="suggest_1">
    <input type='text' id='vdb1'>
    <div id="resultsDIV_1" spry:region="ds1">
    <div spry:repeat="ds1" spry:suggest="{pdb_id}"
    onClick="ds1.setCurrentRowNumber(this.selectedIndex);"
    onchange="ds1.setCurrentRowNumber(this.selectedIndex);">
    <div class="suggest_list">{pdb_id}</div>
    </div>
    </div>
    <span spry:region="ds2" id="subdirSelector">
    <select spry:repeatchildren="ds2" name="subdirSelect">
    <option value="{chain_id}">{chain_id}</option>
    </select>
    </span>
    </div>
    Neither onclick nor onchange functions seem to work; on load
    the second select does fill up with ds2 data (acording to the first
    element of ds1), but when using the suggest box to select something
    different, the selectbox doesn't change accordingly, keeping always
    the same data.
    Am I using the setCurrentRowNumber in the wrong dataset or
    tag?

    I would say if you were to do somthing like this
    var ds1 = new
    Spry.Data.XMLDataSet("API/make_entry_list_xml.php","viperdb/entry",{sortOnLoad:"pdb_id",s ortOrderOnLoad:"ascending",useCache:false});
    see I added the useCache:false
    This will stop the browser from cacheing your xml, thenjust
    add an onclick to some function like say
    update();
    then have update do this
    function update()
    ds1.loadData();
    That should cause the browser to update the data set and
    update your elements now the only downside is IE has a bug well
    more like IE being the bug but anyhow you may have to add things to
    your code to get it to work right in IE, I added in some random
    number script in my JS so that it will append on the end of my DS
    each time so IE thinks its a new XML doc. Hope this helps.

  • Can I parse Text files in Java Script to populate in select boxes.

    The scenario is as follows:
    I have two select boxes, the second one depends on the first one for its values.
    Values corresponding to the selection made in the first select box are available in a text file.
    Can I parse the text file to fill in the values in the second select box through javascript?
    Can any one please help.
    Thanks,
    Ramesh

    This isn't a javascript forum. Java is not Javascript and Javascript is not Java.
    If you actually meant Java...the answer is "maybe, depending on what you're doing".

  • Product Variation Select Box Issue

    HI all! I'm having an issue with the production variations that I have out of stock and they're still showing in the select dropdown menu. I have tried to get support on this but they're telling me that it's something to do with my template. I haven't been able to find any issue with my template though. Upon inspection of the code, I can see that the select box is being set to "display: none" When I disable this, a second select box appears next to the first select box with the correct inventory available selections. Can anyone help me figure out this issue? Thanks in advance!
    {tag_attributes} has been changed to {tag_attributes, vertical, true, false} and all out of stock variations have been disabled.
    UPDATE: On CSS style: select, .selectBox - line 504 "style.css" I forced display: inline-block and now you can see the two select boxes upon page load.
    UPDATE: For the incorrect select box that showed all the product variations despite their disabled status -  i was able to force it to display: none !important --- and it solved this issue. I would still like to know why this was happening if anyone has ideas.
    Thanks!

    Hi mattkrae34,
    What version of SpryMenubar.js are you using? You can find
    the version on the first line of the file.
    Also, do you have a sample URL we can take a look at?
    --== Kin ==--

  • About Select boxes

    I have two select boxes
    one is State : which contains list of states and the Second is City
    Now basing on the condition of Value in State select box i should retreive the correponding cities of that state from the database and fill the second select box
    can any one help me

    Hi,
    Add an action listener on the state list box. On select handle the event and get the selected value. Fetch your required list and populate the city list box. You may also retain the selected value in the first list box as that will help you highlight the selection while you are refreshing all the data.
    If you get the idea just go and you shall find it all in the link http://java.sun.com/docs/books/tutorial/uiswing/events/
    Hope this helps
    Aviroop

  • Passing select boxes as parameter so only using one function

    Hello to all. I"m having trouble with my Javascript. I tried posting this question to some "Javascript" forums and nobody has replied until now I guess they don't know the answer, so I'm hoping that you guys here can answer this kind of question.
    Here was my post
    "Hello. Is there any way that I can pass an actual <select> box as a parameter so I can use only one function in my javascript. Hmm.. here's kind of the situation
    I have two select boxes
    selectbox1 and selectbox2
    and for each select box I have a javascript function
    myfunction1 and myfunction2
    these functions do exactly the same thing
    how can I do it in such a way that it accepts the select box as a parameter and how do I use that parameter when inside the function?"

    You can use the keyword "this" to pass a reference to the <select> box as a parameter to the function.
    In the case of events "this" refers to the object the event is being invoked on - button, selectbox, textfield...
    <script language="javascript">
      function changeCombo(theSelectBox){
        alert('you changed ' + theSelectBox.name);
        alert("value = " + theSelectBox.value);
    </script>
    <hr>
    Letter: <select name="s1" onchange="changeCombo(this)">
      <option value="a">a
      <option value="b">b
      <option value="c">c
    </select>
    Number: <select name="s2" onchange="changeCombo(this)">
      <option value="1">1
      <option value="2">2
      <option value="3">3
    </select>

  • Right clicking brings up two dialog boxes

    Hello,
    Using Internet Explorer no problem with right clicking on a mailbox entry.
    Using FireFox version 3.63 right clicking my mail item brings up two selection boxes.
    Should only be just one.
    Previous Firefox version like 3.60 was ok.
    See screenshot (or http) for example:
    Thanks, [email protected]
    [IMG]http://i8.photobucket.com/albums/a40/VMartell/ff-problem.jpg[/IMG]
    == This happened ==
    Every time Firefox opened
    == with version 3.63

    Today I reinstalled an old FireFox version 3.59 and it corrected the problem.
    Then I set FireFox "Options" to NOT automatically check for updates.
    If you want to see the "double dialogue box problem" with FF version 3.63, I put the screenshot on Photobucket ... this is the link to it:
    http://i8.photobucket.com/albums/a40/VMartell/ff-problem.jpg

  • How to create editable select box in jsp page

    hi,
    i got som peculiar requirement in my jsp page.i have my page like this.
    <html>
    <body>
    <form name="test">
    <select name="test">
    <option value="one">USA</option>
    <option value="two">India</option>
    <option value="three">UAE</option>
    </select>
    </body>
    </html>
    this is one of the select box in my jsp page.
    now i want to change the look and feel of select box..
    1-dont want to show the scrollbar means the right side arrow which allows to see the total options in select box.
    it should look like normal text box.
    2-roveer apert from the existing values if there is no matching value user must be allowed to enter his own value in above select box..
    how i can solve this problen..
    regards,
    sam

    Is that maybe a browser memory auto-complete thing? It works on Netscape 7.2. But no, it's not a browser auto-complete thing (does NS have that? IE does... either way, I would've disabled that). It's definitely a Javascript trick, I'm sure of that. I know I haven't sent mail to all people in my address book from my work PC, but it doesn't stop them from showing in the list as I type...
    Unless there is a special HTML tag option or browser extension that I've never heard of that allows you to supply a set of values to a text input field for auto-completion (as opposed to the browser remembering what was typed).

  • 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

  • Can I transfer an application from one computer to another?

    My school uses InDesign CS4 to do newspaper layout in journalism class, and my teacher (an old ****) just upgraded his home desktop from Mac 9 to Snow Leopard. Before this year's much-needed upgrade, all of the computers in the class were running Mac

  • Error while fetching the data from BO XI Web Intelligence Tool

    I am using .Net Web Service SDK to get the the data from Business Object Report. When I request the report I am getting an error saying "getDocumentInformation exception (WRE 99999)". I am on BO XI R2 and the underlying database to generate the repor

  • Reports in process server....HELP!!!!!

    Hi, I have installed 9i R2 Infrastructure and Application server on one machine and everything is running fine except the OEM shows that Report in process server rep_<host> is down, then I started it using command "rwserver server=rep_<host>" and it

  • Problem with database connectivity

    Hi guys, I'm having a problem with database connectivity . I'm using the mySQL database & org.gjt.mm.mysql driver. I've kept the org folder under the directory where the Database.java program is residing . My program is as follows: import java.sql.*;

  • Render every single video

    Why do I need to render every single video that I imported and and filters too? Why is that so?