JSP form value use

I have a simple JSP form that gets three values. I need to use one of these values in a query before I hit the Form SUBMIT button. Is there a way to do this?

Do you mean to say you need the values in the form fields entered by user before submitting the page..?
In that case you can call a javascript function on click of the button and retrieve the values and after that submit the button.
Hope this helps.
Regards,
Anupama

Similar Messages

  • JSP form values lost upon servlet request (RequestDispatcher)

    Hello,
    I have a query screen (jsp) that calls a servlet and gets results. However, although the results or errors display just fine (I do a setAttribute for them), I lose the initial values in the query form (values that the user input - which are stored in the request object). Shouldn't those values be maintained and displayed, since I'm using the RequestDispatcher and thus, I should have the same request object? Thank you, C Turner
    *****My JSP (the related code)*****
    <jsp:useBean id="form" class="com.foo.ActivityBean" scope="session">
    <jsp:setProperty name="form" property="*"
    </jsp:useBean>
    <HTML>
    <BODY>
    <FORM ACTION="ActivityFormHandler" METHOD="POST">
    <P><B>From Date</B>
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="fromDate"/>">
    <P><B>To Date</B>
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="toDate"/>">
    *****Java from my HttpServlet, ActivityFormHandler (acting as a formhandler)*****
    if (errors.size() == 0) {
    ActivityBean myActivityBean = new ActivityBean();
    myActivityBean.setBeanQueryValues(acctNumber, department, fromDate, toDate);
    Vector resultsVector = null;
    try {
    resultsVector = myActivityBean.executeQuery();
    } catch (CreateException ce) {
    errors.add("There was a problem retrieving the requested data from the database.");
    request.setAttribute("results", resultsVector);
    } else {
    //Data is not okay.
    String[] errorArray = (String[])errors.toArray(new String[errors.size()]);
    request.setAttribute("errors", errorArray);
    RequestDispatcher rd;
    rd = getServletContext().getRequestDispatcher("/public_html/ActivityQuery.jsp");
    //rd.forward(request, response);
    rd.include(request, response);

    For those interested in my question, here's what I figured out.
    Instead of:
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="fromDate"/>">
    Use:
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<%out.print(request.getParameter("fromDate"));%>">
    This allows the input field to persist the query value instead of blanking it out when the results are displayed. -ct

  • Default form value using sql with bind variable

    I wish to create a form based upon a table with a foreign key. I wish to add a field to the form that is an uneditable text field with a default value using sql of 'select name from other_table where other_table_id = ?' where ? is a bind variable defined by a hidden field which is the value of the foreign key identified at runtime. How can this be done?
    null

    I don't think that will work. I have multiple people accessing the Portal at the same time with the same login (or lack of as public will be the most common user). I could set it easily enough as the value is passed to the form by a link object, so I could add it to the before page plsql block and set the value. But I am uncertain how it will behave in a multi-user mutlitasking environment.
    Maybe I should describe what I am looking to accomplish. I want to create a display above a form that will list static details from other tables (i.e. when editing a user's phone number, which is in one table, you want the user to see the person's name, which is in another table, and the form is based upon the phone table) ...
    Just as I am thinking about it, I thought of an idea. I could put some specific code in the before displaying page plsql section to query the database and use htp to output the information for data not in the table the form is based upon. I will try this and see how it works. It would have been nice to have just created a field that is not editable and had a default value, but this should work as well.
    Let me know if you see any problem with this or if you have any better suggestions.
    Thanks for the fast response.

  • Making a JSP Form read only based on the form value present in DB

    I need suggestions/examples as i am newbie into java stream.
    I have two JSP pages 'Add Page' and 'Edit Page' .
    Add Page -> In add Page,I have many text boxes,select drop-downs options. In one select drop-down I have values as Locked and open .I can save this page contents in DB by entering those form values.
    Edit Page -> In eidtPage,once saved in DB, based on 'select drop-down- Locked and open' If it is locked i have to make all the fields (text boxes and select drop downs) as read only and if it is open i have to make it editable.
    I am taking all the values from DB,setting to 'form bean' and then setting up the values in session and forwarding it to JSP page to populate there .I am using beehive net UI tages in JSP. Please help me out.

    Not sure I'm following what you want, but this might help:
    In your select tag, put something like an 'onchange' event that calls a javascript function. In the javascript function it you add code to enable or disable your other fields based on the item selected from the drop down box.
    To determine what item was selected in a select tag, you write something like the following. I'm not sure of the exact syntax. You can look it up in a javascript book:
    var optionSelected = document.forms[0].selectTagName.options[document.forms[0].selectTagName.selectedIndex].value;
    To enable or disable a textfield, search for this in google:
    'jquery disable input'

  • How to Disable a entire JSP form based on single value

    Hi,
    My requirement is I have to disbale a JSP form based on getting single value from the drop down box. Please suggust me some ideas.
    Highly aprreciated
    Thanks In advance
    Anbr19

    Well as said by my fellow it could be easily acheived by javscript
    say i'm assuming the dropdown has set of value under a form named SampleForm..
    here is how you do using javascript
    <script language="javascript">
    function disable(txt){
       if(txt == '<Condition Value>'){
           for(var i =0 ; i < document.SampleForm.length ;i++)         
               document.SampleForm.elements.disabled = true;
    </script>
    <form name="SampleForm">
    <select name="dropdown" onchage="disable(this.value)">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    </form>
    hope this might help :)
    REGARDS,
    RaHuL

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • CRM 2011: Can you control which form is used based not security roles, but on a field value?

    I see that you can control which form is used based on security roles, but can you control it based on other field values?  I'd like a new record to use a different form until a given status is updated.  I have a status of draft and active. So
    it would be nice if I could use form1 for those in draft, form2 for those that are active.  But I only see where you can control that via the security roles.
    I can code all of this via JavaScript, but having the ability to use two separate forms would be nice.  Is that even possible.
    Best regards,
    Jon Gregory Rothlander

    Hello,
    Recheck following article - http://gonzaloruizcrm.blogspot.com/2014/11/avoiding-form-reload-when-switching-crm.html
    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

  • Unable to populate the default value  using form personalization

    Hi, I need to default a value in order managemnt for waybill number
    shipping -- transaction - delivery - detail --
    In Order management
    Shipping - Transactions
    Source system -- Order management
    From Order number - Any ordernumber
    say find
    I want to default this Detail ( xxxxx) as Way bill
    value of :DLVB.DETAIL_LABEL
    I have put the following condition on form personalization
    Condition tab
    Triger event
    When new record instance
    Trigger object
    dlvy_s
    Processing mode both
    Actions tab
    Property
    Object type Item
    Target Object DLVY_S.WAYBILL
    Property name Value
    Value
    :DLVB.DETAIL_LABEL
    but it is not defaulting... Appreciate if any one has idea what is wrong in this.
    Edited by: 885022 on Oct 3, 2011 11:31 AM
    Edited by: 885022 on Oct 3, 2011 11:33 AM

    yes Srini
    as we dont have any option via personalization to set the default values ,it can be done through controller extension ,
    in processRequest method of extended controllere get the control for that particular field where u want to set the default value and set the value using fieldbean.setValue(pagecontext,value);
    in case of any particular case ,please post in the forum
    thanx
    Pratap

  • How do I retain a PDF form widget's design when setting its value using Javacript in Acrobat?

    I've been experimenting with interactive PDF forms in InDesign and JS in Acrobat. I think I've encountered something that might be a bug: widget design is overriden when using Javascript to set the field's value in Acrobat. Here's what a checkbox, for example, should look like when checked:
    However performing:
    var f = this.getField("Checkbox");
    f.value = "Yes";
    in the JS Console results in the widget's appearance defaulting to acrobat's:
    I've tried every single widget property documented in Acrobat's Javascript API Reference to no avail. Initially, checking/unchecking using the mouse works fine. Once the value has been set using JS, Acrobat's default black check character is used for all subsequent toggling, including when using the mouse...
    How does InDesign export interactive PDFs with custom icons for widgets? Is there any way to enforce the use of those icons using JS in Acrobat Pro? What's the difference between selecting a checkbox or a radio button using the mouse and setting its value using JS?

    I thought it might be the case, too, but all widgets have the same properties both before and after setting the value with JS. I did this check using all documented properties in Acrobat JS Reference in an attempt to figure out what might be going on.
    By the way, I don't think Indesign necessarily uses glyphs for the checked state of widgets, although in this case a glyph is used (albeit with different stroke and fill colours for the glyph, acrobat doesn't allow setting these properties AFAIK). With Indesign CS6 it seems you can practically use any Indesign tool to design the widget's On and Off states. So I'm thinking that maybe Indesign exports these with button-like properties where there are no restrictions on appearance (I think there is an "icon" property/object for buttons or something like that). However Acrobat treats them as checkboxes, so if that is the case it is more of a hack. Is there a way to probe an object's various properties other than using JS or the properties pop-up dialog?

  • How to set a form element value using javascript?

    Hello,
    I have been using the following two functions in AS 9.0.2 to set form values in javascript and it works correctly. However, the same code does not work in AS 10.1.2.0.2. Would appreciate if someone could let me know how to set form elements using Javascript(onchange of a field).
    function set_item_value(p_field_name, p_value)
    var v_index, v_full_name;
    for(v_index=0; v_index<document.forms[0].length; v_index++)
    v_full_name = document.forms[0].elements[v_index].name.split
    if (v_full_name[2] == p_field_name)
    document.forms[0].elements[v_index].value = p_value;
    function get_item_value(p_field_name)
    var v_index, v_full_name, v_return="";
    for(v_index=0; v_index<document.forms[0].length; v_index++)
    v_full_name = document.forms[0].elements[v_index].name.split
    if(v_full_name[2] == p_field_name)
    if(document.forms[0].elements[v_index].type != "radio")
    v_return = document.forms[0].elements[v_index].value;
    else
    if(document.forms[0].elements[v_index].checked)
    v_return = document.forms[0].elements[v_index].value;
    if(v_return == " ")
    v_return = "";
    return v_return;
    Thanks
    Dev

    This is not the best way to write JavaScript in Portal environment!
    You can't be sure that a form is the first in the html source!
    In Portal you change the order of your portlets, and also you can have several instances of the same portlet on the same page!!!
    You should use qualified form and field names!
    Please check the following JPDK methods:
    UrlUtils.htmlFormName
    HttpPortletRendererUtil.portletParameter

  • In javascript  how to use jsp tag value

    i want to change td value while clicking the options.In the td contains jsp page.while clicking the options i want to load particular jsp within in the td.i change the td value using innerHTML by assigning value this format <jsp:include page="..."/>.It's gives some error .
    JspTranslate:Attribute has no value
    code:
    function rightPageload(strPage) {
    pageval='<jsp:include page="/jsp/library/"'+strPage+'"/>'
    document.getElementById("d1").innerHTML=pageval;
    }

    Do you want to use taglibs or develop custom tags? Either way take a look at these:
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags.html
    http://www.stardeveloper.com/articles/display.html?article=2001081301&page=1
    http://www.onjava.com/pub/a/onjava/2000/12/15/jsp_custom_tags.html
    http://jakarta.apache.org/taglibs/tutorial.html
    http://www.ibm.com/developerworks/edu/j-dw-java-custom-i.html
    http://www.herongyang.com/jsp/tag.html

  • Writing XML document using form values

    Being new to java/xml I'm strugling with this task:
    I have a web form and I need to pass the values from the form to a class that will then create an xml file using the form values.
    I've looked through the JAXP tutorial and Sun's XML tutorial but can't find anything that would suit my needs.
    Could anyone help me on how I should go about doing this?
    Does anyone have any sample code?

    with JAXP, you can either :
    - build a new XML document from scratch, using DOM, and append each node, each value,
    - create a style sheet that generates an XML document, receiving the web form values as parameters, processed with XSLT.

  • Get form field value using an offset

    I have a Form created using Perl that has a table with a row for each invoice in a large table. I display all the rows in a table and allow the user to edit some info for each record:
    for ($item_cntr = 0; $cntr < $record_cnt; ++$item_cntr)
    { print qq(<tr>
    <td><input type="text" name="c_freight_$item_cntr" value="$i_freight[$item_cntr]" onBlur="linetotal($item_cntr)" ></td>
    <td><input type="text" name="c_miscamt_$item_cntr" value="$i_miscamt[$item_cntr]" ></td>
    <td><input type="text" name="c_price_$item_cntr" value="$i_price[$item_cntr]" ></td>
    </tr>);
    I want to create a Function that is called when they change the Freight value and that causes the rows total Price (freight + miscamt = price) to be calculated again (without hitting a Submit button on the Form).
    I created a Function:
    function linetotal(whatline) {
         var fixed_freight = "document.editform.c_freight_" + whatline;
         var fixed_misc = "document.editform.c_miscamt_" + whatline;
    var linetotal = parseFloat(fixed_freight.value) + parseFloat(fixed_misc.value);
    document.editform.c_price_whatline.value = linetotal; } }
    So, if the first row in the table is 0, then the Function is passed "0" and should get the value of the form fields:
    'c_freight_0' and 'c_miscamt_0' and set 'c_price_0' to a new value in the form.
    The fixed_freight is showing that the string it has is correct, but it does not get the value from the form. Any ideas?

    DrClap wrote:
    DrLaszloJamf wrote:
    DrClap wrote:
    Although there are [Java sites|http://www.javaranch.com/] which do have an [HTML and Javascript forum|http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=20].
    Don't forget the free hugs forum there, too!
    You must mean [this one|http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=44].
    Oh yeah. Are you a JavaRanch regular, Dr.C? I was for a while, but not recently.

  • How to make countdowntimer in java bean to use in jsp form

    i make an aplication in jsp with XHTML MP format..i have problem to maka a countdowntimer in java bean to use in the jsp form.could anyone help me with this problem

    Use JHelp, downloadable from Sun. This is a quit big package, you have to read a lot before applying.
    http://java.sun.com/products/jfc/tsc/articles/javahelp/index.html
    enjoy
    sergio

  • How can I write the action attribute of a form dynamically using JSP

    I would like to do something like this:
    If the 'Accept-Language' of the http request is 'en', write out this in JSP:
    <form name='myform action="http://127.0.0.1/myservlet/en/>
    else if
    the 'accept-language' is 'es', write out this instead:
    <form name='myform action="http://127.0.0.1/myservlet/es/>
    else if no match
    <form name='myform action="http://127.0.0.1/myservlet/default/>
    How can I do that in JSP? I think this is simple enough so that I don' t need to use any of the Java Web framework/Java Beans.
    Thank you for any help.

    you can use a simple javascript for this:
    function setAction(lang){
       if(lang=="en"){
         document.forms[0].action="putYourservletUrlhere";
       }else if(lang=="es"){
         document.forms[0].action="putYourservletUrlhere";
       }else{
         document.forms[0].action="putYourservletUrlhere";
    }

Maybe you are looking for