Changing value of one input field based on other.
Hello All,
I am having this interesting situation with changing a value of a INPUT form in jsp based on another INPUT.
Lets say my form has 3 INPUT variables.
1. YEAR (COMBOBOX) (using the SELECT OPTION)
2. MONTH (COMBOBOX)(using the SELECT OPTION)
3. TEXT
If the user sets the year to 2003, I want to show all 12 months. But if the user sets the year to 2004, I want to show only the month of Jan and then not allow the user to change the value.
I also need both these values to go as form input when the user hits submit.
After reading the JSP/Javascript issues other people are having with regard to accessing variables across these two(i.e jsp and javascript), it looks like ther is no easy way to achieve this using
"onChange=setValue()" on the YEAR field.
What would be the best way to do this?
Thanks,
Chhaya
u can use javascript funtion
u can pass day month and year wiich will return false if wrong date was selected like leap year,selecting 31 feb etc.
function validatedate(dd,mm,yy)
cday=dd
aday=dd
cmonth=mm
cyear=yy
leapyearcal=cyear%400
if(leapyearcal==0)
leapyear="OK"
else
{ leapyearcal=cyear%100
if(leapyearcal==0)
leapyear="no"
else
leapyearcal=cyear%4
if(leapyearcal==0)
leapyear="OK"
else
leapyear="no"
if ((cmonth==1)||(cmonth==3) || (cmonth==5) || (cmonth==7) || (cmonth==8)|| (cmonth==10) || (cmonth==12))
aday=31
if ((cmonth==4)||(cmonth==6) || (cmonth==9) || (cmonth==11))
aday=30
if ((cmonth==2)&& (leapyear=="OK"))
aday=29
else if (cmonth==2)
aday=28
if (cday>aday)
return true
else
return false
}
Similar Messages
-
How to change the value from one input control to another input control?
Hi Experts,
I want to change the value from one input control to another input control. For Example if i change month in first tab. it should reflect in second tab also. How should we acheive through input control or some other option.
Here I attached screen shot.Please help me for thisHi,
It is not possible to have Input controll in all tabs that will be set from another .
But There is one workaround .
Follow the link below .
http://davidlai101.com/blog/2013/08/13/web-intelligence-input-control-that-affects-all-tabs/ -
Disabling one input field if i enter text in second inputfield
Hi,
I am new to WebDynpro. My problem is very simple. I have two input fields. When i enter text in one input field i want the second input field to be disabled & Vice versa. The idea is that i want to give the user the option to enter in only 1 input field of his choice. The second input field should automatically get disabled. He can choose any input field of his choice. The second one should get disabled.
EG: Assume that there are two input fields "Item No" & "Material". The user wants do a search using any one of these parameters, but not both. So, when he chooses to do a search based on "Item No", the "Material" input field should be greyed out(disabled). And, vice versa. The user may decide to choose any one of these fields.
Please advise.This is not possible because there is no "onFocus" event on the input field.
But you could use two radio buttons R1, R2 to enable exactly one of the input fields F1, F2 at a time.
In the view designer, set R1.keyToSelect = "1", R2.keyToSelect = "2".
Bind R1.selectedKey and R2.selectedKey to a common context attribute A (type string).
If (at runtime) A contains "1", radio button R1 is selected, if A contains "2", radio button R2 is selected.
To enable input field F1 exactly if R1 is selected:
Create a calculated boolean attribute E1 that returns the boolean value ("1".equals(A)), bind property F1.enabled to E1. Do the same for F2.
Armin -
How to enable/disable the input fields based on the data entered in the web dynpro application abap? If the user enters data in one input field then only the next input field should be enabled else it should be in disabled state. Please guide.
Hi,
Try this code.
First create a attribute with the name readonly of type wdy_boolean and bind it read_only property of input field of which is you want to enable or disable.
Next go to Init method.
Set the readonly value as 'X'.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_visible TYPE wd_this->element_context-visible.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* @TODO fill attribute
* lv_visible = 1.
* set single attribute
lo_el_context->set_attribute(
name = `READONLY`
value = 'X').
After that Go to the Action ENTER.
First read the input field ( first input field, which is value entered field) , next give a condition
if input value is not initial then set the readonly value is ' '.
DATA lo_nd_input TYPE REF TO if_wd_context_node.
DATA lo_el_input TYPE REF TO if_wd_context_element.
DATA ls_input TYPE wd_this->element_input.
DATA lv_vbeln TYPE wd_this->element_input-vbeln.
* navigate from <CONTEXT> to <INPUT> via lead selection
lo_nd_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
* @TODO handle non existant child
* IF lo_nd_input IS INITIAL.
* ENDIF.
* get element via lead selection
lo_el_input = lo_nd_input->get_element( ).
* @TODO handle not set lead selection
IF lo_el_input IS INITIAL.
ENDIF.
* get single attribute
lo_el_input->get_attribute(
EXPORTING
name = `VBELN`
IMPORTING
value = lv_vbeln ).
if lv_vbeln IS not INITIAL.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_visible TYPE wd_this->element_context-visible.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* @TODO fill attribute
* lv_visible = 1.
* set single attribute
lo_el_context->set_attribute(
name = `READONLY`
value = ' ' ). -
Mixing Html/JSP - Is it possible to retain value in "file" input field?
I have a jsp page with the following snippet:
<% String text1 = (String)session.getAttribute("text1");
if(text1 == null) {
text1 = " "; }
//get more attributes here
%>
<form name="file" action="checkFields_images.jsp" method="post" enctype="multipart/form-data">
<input type="text" size="15" name="text1" value="<% =text1 %>"><br>
<input type="file" name="image1" />
<br>
<input type="text" size="15" name="text2">
<br>
<input type="submit" name="submit" value="submit">
</form>
...upon submission, it will go to a jsp that will check the fields for blanks or errors. If there are errors, the page will forward the user BACK to the original page, and each field that had an entry will be displayed with what the user had entered.
The way my code operates is when the user hits the submit button, the jsp page that checks the fields is also setting the values submitted in session attributes. Those of you familiar with JSP code will know what I mean.
That way when the page is redisplayed the "value" attributes of each <input> field will be set to what the user entered by way of such:
<input type="text" name="text1" value="<%=text1%>">
where <%=text1%> is a java variable set to the session attribute value for this <input> field.
Now I know that the <input type="file> field has a value attribute, but I don't believe it is something that can be set. So how do I workaround this? I just want the field to display the file name the user had selected. I've worked with mixing JavaScript and Java code, but there are certain things you can and can't do, and I'm coming up with any "can do's" for this one.
Any suggestions are appreciated
Thank You,
Love2JavaYou are absolutely correct.
For security reasons, you can't specify a value for the input type="file".
Here is one suggestion, of how I would see it work in a perfect world.
- The file is uploaded and retained on the server
- You send back a page without an input type="file"
- The user fixes whatever fields they got wrong and submits again
- The server picks up the correct fields, along with the file sent with the "bad" request, and then continues as normal.
In this way, you only have to upload the file once.
Instead of regenerating the <input type="file">, it would generate something like "File already uploaded. Correct other fields"
pros:
- Don't have to worry about repopulating the input type="file"
- user only uploads the file once
cons:
- if the user wants to change the file? Maybe another link?
- must retain file on server somewhere, and find it later.
I didn't say it was easy, but it seems the most sensible approach to me.
Cheers,
evnafets -
Auto population of data to fields based on other input field.
In overview screen, I have one input field "Business Partner" which contain search help. As soon as business partner selected from dropdown, the other input fields like Name, Address, City, state should automatically populated without hit of 'ENTER' key.
I verified with method DO_PREPARE_OUTPUT, but it is triggering only by hitting ENTER key. Is there any event or method which will trigger after business partner selected from dropdown? or any other option to achieve to auto populate the fields.
Please find attached screen.
Thanks in advance.Hi Narayana,
You can use the get p method for setting up the values without pressing the enter.
CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_picklist.
WHEN if_bsp_wd_model_setter_getter=>fp_server_event.
rv_value = 'AI_SELECT'.( you can give here the event name)
WHEN OTHERS.
ENDCASE.
Define event with the same name above( AI_SELECT),
You can set the value of fields based on the first field value within this event.
Thanks,
Dharmakasi. -
How to save changed data from a input field to the source structure
Hi,
I have a small problem with the onChange event with HTML input fields.
When changing a value of a input field or by creating a new value for a field the OnChange event is called by moving away the mouse pointer....
get_form_field( 'field_name' ).
But is it possible to write back the new value in the source field ls_screenstructure_field1 without using the OnInputProcessing?
I ask because my application´s structures have a lot of fields that should be filled and changed by input fields.
It´s not comfortable to request every new value with .. = request->get_form_field(... .
Thanks for helping.
Cheers,
Andréyou wanted a onchange for a htmlb:inputfield which would also trigger server event. try the following code.
<htmlb:inputField id = "test"
alignment = "LEFT"
size = "6"
required = "TRUE"
doValidate = "TRUE"
type = "INTEGER"
/>
<bsp:htmlbEvent id="myid" onClick="myonclick" name="ValueChanged" />
<script for="test" event=onchange type="text/javascript">
alert(this.value);
ValueChanged();
</SCRIPT>
if the value in the inputfield is changed it would trigger a alert at the client side and also trigger a server event. now you can caputre the value in oninputprocessing.
Hope this helps.
do let us know if you need help in how to capture this value in oninputprocessing.
Regards
Raja -
Capture value from the input field
Hello All,
I'm new to BSP.
I have a small querry.
I have a input field.
beside this a push button.
if i enter a value in the input field and press the push button, i need to capture the value from the input field and pass it to a variable contained in a class.
i'm attaching the layout code here.
but i'm not knowing what to write in the event(on input processing)
<u><b>Layout code </b></u>
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title = "Page to take the value from the screen and pass to the class "
marginBottom = "100"
marginLeft = "250"
marginRight = "100"
marginTop = "100"
scrolling = " AUTO" >
<htmlb:form>
<htmlb:tray id = "tray1"
hasMargin = "TRUE"
title = "Value Capture"
width = "350" >
<htmlb:textView text = "Enter a value"
design = "emphasized"
textColor = "negative" >
</htmlb:textView>
<br>
<htmlb:inputField alignment = "left"
id = "gv_var"
required = "true"
type = "STRING"
design = "standard" />
<htmlb:button design = "emphasized"
id = "button"
text = "SUBMIT"
onClick = "btn_click" />
</br>
</htmlb:tray>
</htmlb:form>
</htmlb:page>
</htmlb:content>
eventhandleron input processing code
DATA: event TYPE REF TO if_htmlb_data.
event = CL_HTMLB_MANAGER=>get_event_ex( request ).
IF event->EVENT_NAME = 'button' AND event->EVENT_TYPE = 'click'.
ENDIF.HI BSPian,
htmlb:inputField value = "<%= v_value %>"
id = "gv_var"
required = "true"
size = "10"
type = "STRING"
maxlength = "10"
design = "standard" />
Here u mean to say that v_value must be one more field type string. is it so ?
But i want to see the value in the same input field
id ="gv_var". i.e if i enter the value "BSPian" in the input field and press "submit" the internal processing will be done as told by u and after that ,on the screen i want to keep that value till i end that session.
i passed a variable v_value in the inputfield value but it's not working ..
regards,
deepu. -
PM Notification - Hide fields based on other field's value
Hello experts,
I am looking for an user exit which allows me to hide some fields based on other field's value.
For example, I have field 1 and field 2. When I open my notification, if the value of field 2 is 'aaa', field 1 has to be hidden.
There should be an user exit but I can't find it...
Thanks for your help!Hi everyone,
Any thoughts? any help is appreciated...
Thanks -
How to prepopulate value in webapps input fields or for any custom fields in for any other forms?
What do you want to populate the form with?
-
How to restrict the user to enter only numeric values in a input field
How to restrict the user to enter only numeric values in a input field.
For example,
i have an input field in that i would like to enter
only numeric values. no special characters,alphabets .
reply ASAPHi Venuthurupalli,
As valery has said once you select the value to be of type integer,once you perform an action it will be validated and error message that non numeric characters are there will be shown. If you want to set additional constraints like max value, min value etc you can use simple types for it.
On the project structure on left hand side under local dictionary ->datatypes->simple types create a simple type of type integer
The attribute which you are binding to value property ;make its type as simple type which you made
Hope this helps you
Regards
Rohit -
Default Value in Numeric Input Field in Visual Composer Application
Hi All,
I have developed a visual composer application which has a numeric input field for Hours.
It is mapped to a backend module.
We are using portal 7.31
The problem is that the deafult value of this input field is "0", but the rquirement is to display as "0.0"
The functionality has been tested with input values in decimals and works fine. The problem is when the screen first populates, that field should show "0.0" .
Please advise.
ThanksHi Soumya Chanda,
I don't know of an agreeable way around it. You could have a textual input, but then it doesn't have the numeric control behavior, plus you need to handle incorrect typing (alphanumeric notes).
Sorry! -
Hi All,
I am a newbie to ABAP Webdynpro.I would liketo know how should I get the value from an input field at runtime?
Thanks,MuktaBy reading the context attribute which bound to inputfield, you can get the value.
Say you have a node called 'MAIN_NODE' and has the attribute 'INPUT_VALUE', which is bound to the Inputfield.
DATA LO_ND_MAIN_NODE TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_MAIN_NODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_MAIN_NODE TYPE WD_THIS->ELEMENT_MAIN_NODE.
DATA LV_INP_VALUE LIKE LS_MAIN_NODE-INP_VALUE.
* navigate from <CONTEXT> to <MAIN_NODE> via lead selection
LO_ND_MAIN_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'MAIN_NODE' ).
* get element via lead selection
LO_EL_MAIN_NODE = LO_ND_MAIN_NODE->GET_ELEMENT( ).
* get single attribute
LO_EL_MAIN_NODE->GET_ATTRIBUTE(
EXPORTING
NAME = `INPUT_VALUE`
IMPORTING
VALUE = LV_INP_VALUE ). "LV_INP_VALUE will have the value of inputfield
Raja T
Message was edited by:
Raja Thangamani -
How to display F4 values in one field based on other field selection
Hi All,
How to hide a UI element (i.e Link to action) highlited for Normal User and display the same to super user.
Component Name : /SAPSRM/WDC_DODC_SC_GAF_C
2.Can i know how to display the entries in supplier field based on Product category selection.
Right now all the entries are getting displayed in the supplier field.
I want to display only entries based on Product category.
Search Help Name : BBP_BUPA_CLL_PARTNER
Component Name : /SAPSRM/WDC_DODC_SC_I_LIM
How to enhance the web dynpro component with the filtered values.
Regards,
Krish.Hi Ashvin,
Thanks for the document. In the search help there is a standard FM which is getting executed.
Can i enhance that FM or should i copy and edit.
BBP_F4IF_SHLP_EXIT_CLL_PARTNER
If i creata a Z FM and make changes how to pass that values to my standard Component View UI Element.
If not then suggest me some alternative.
Regards,
Krish -
Value of the input field changing automatically on click of enter
I was trying to write a simple report that has a single input field with a f4 help for a directory browser attached. the input field can only be filled using the f4 help ( achieved through function module DYNP_VALUES_UPDATE) . The problem is after the input field is populatd if i click on enter or press f8 the text in the input field changes automatically. Please can anyone find the reason for this behaviour and provide a solution .Thanks in advance.report code attached.
Regards,
Kiran A.
REPORT zpgm_md61_error1.
PARAMETERS: p_file TYPE string MODIF ID abc LOWER CASE .
DATA: dyname TYPE programm,
dynumb TYPE sy-dynnr.
DATA: dynpfields TYPE TABLE OF dynpread WITH HEADER LINE.
DATA: lv_folder TYPE string,
sel_folder TYPE string.
AT SELECTION-SCREEN OUTPUT.
PERFORM disable.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
initial_folder = lv_folder
CHANGING
selected_folder = sel_folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
dynpfields-fieldname = 'P_FILE'.
MOVE sel_folder TO dynpfields-fieldvalue.
APPEND dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = dyname
dynumb = dynumb
TABLES
dynpfields = dynpfields.
FORM disable.
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDFORM. "dISABLEHello Kiran,
This is because you've defined the field as TYPE STRING.
Change the declaration & the problem should be solved:
PARAMETERS: p_file TYPE dynfieldvalue MODIF ID abc LOWER CASE .
BR,
Suhas
Maybe you are looking for
-
To remove leading zeroes and take directly from IDOC(Segment field) to file
Hi SapAll. i have got a simple requirement in a idoc to file Interface. here in a sender Idoc there will be one segment with one field,the requirement is to remove leading zeroes and take directly the data from this field and map to one of the field
-
I want to go back to firefox 3,6. I uninstalled FF 4 because it's buggy. I don't like it. There's a dialog box that keeps opening. That never happened before. It's damned annoying and not necessary. There are a number of items that no longer are comp
-
How To Resolve Droid Messaging stops after the update.
Here is a temp fix for those of you who are at your witts end and have found no solution. 1) settings/apps/all......select messaging>disable< 2) Go to Play Store....Search >messaging classsic kitkat 4.4< .....Install
-
Sessions across Web Applications (WARs)
I've heard that you can't share session information (http session) across web applications or war files in the j2ee framework. However, I haven't seen any proof of this? I'm struggling to find information telling that I can't do this. Can someone ela
-
Hi, I am installing mySAP ERP 2004 IDES version. (SQL Server 2000) I have installed the Central component. While installing the database component recieved the below error message. (DB) INFO: connected to DB Please look also into "C:\Program Files\sa