on 2006 Mar 02 6:23 AM
I have a view that contains the following code:
<script defer language="Javascript" >
function text_edit(defaultSelected,defaultValue,myForm){
if (selectedText == ""){
selectedText = defaultSelected;
selectedValue = defaultValue;
}
customTextObject.cSelected = selectedText;
customTextObject.cValue = selectedValue;
textEditURL = "TextEdit.htm?option=" + selectedText + "&value=" + selectedValue;
<b>customValue</b> = window.showModalDialog(textEditURL,customTextObject,customPageFeatures);
var x = document.getElementById('customVal');
x.value = customValue;
<script>
.....
<htmlb:inputField id = "customVal"
visible = "FALSE"
value = "<%=<b>lv_customvalue</b>%>"/>
<htmlb:button text = "Edit"
onClientClick = "text_edit('<%=lv_selection%>','<%=lv_selectionvalue%>',this.form)"/>
But is says that x is null, meaning document.getElementById('customVal') doesnt get any value. And so, I cannot put the value of the javascript variable to an ABAP variable.
How can I transfer the value of my javascript variable(<b>customValue</b>) to an ABAP variable(<b>lv_customvalue</b>)?
Is there another way to get the name of the form?
Also,
document.all.customVal
is null.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you are using sub-controllers the you have to concatenate controller's ID to your inputField's ID.
e.g. If your subcontroller's id is <b>mySubController</b>
and inputField's ID is 'customVal'
then you can get inputfield's value using code
document.all("mySubController_customVal").value;
Try it once also.
Regards,
Narinder Hartala
TIP: You don't have to hardcode the subcontroller ID. In the view coding you can always use controller->component_id to get the current, complete subcontroller ID. That way if your view is reused by one than one controller or a different levels your code doesn't break:
document.all("<%= controller->component_id %>_customVal").value;
Thanks Thomas! It's working. I have a new problem.
After setting the value for the hidden fields, I want to refresh the page and so call a BAPI to update the data in the table. Since this is a view, I will put the BAPI call to the DO_HANDLE_EVENT method. Is this correct? If so, my problem is how can I say that when the refresh is done, it will call the BAPI? I don't have something that would trigger the event.
<bsp:htmlbEvent id = "myid"
onClick = "myonclick"
name = "ValueChanged" />
<script for="IP1" event=onchange type="text/javascript">
ValueChanged();
</SCRIPT>
in the above script for="IP1" is the name of the hidden form field.
any value change in that field will trigger serverside event.
Regards
Raja
Hi Raja!
This is my code:
<htmlb:inputField id = "customVal"
type = "string"
visible = "false"
value="<%=lv_text%>"/>
<bsp:htmlbEvent id = "myid"
onClick = "update_custom_value"
name = "ValueChanged" />
<script for="customVal"
event=onchange
type="text/javascript">
ValueChanged();
</SCRIPT>
then a javascript call will place a value on the hidden field, like this:
document.all("<%= controller->component_id %>_customVal").value = customValue;
When the value is transferred to the hidden field. I want to call a BAPI. But nothing happens when the hidden field is filled-up with a value. Is there something wrong with my code? Note that this is a view and not a BSP page.
I tried calling the ValueChanged in my javascript code but it shows "page cannot be displayed". What I want is to refresh the page and call the BAPI on refresh. How can I do that?
I added this code in DO_HANDLE_EVENT:
CASE htmlb_event->server_event.
WHEN 'update_custom_value'.
*do call bapi here...
ENDCASE.
Is this correct?
to place a http breakpoint, first external debugging should be activated
se80->utilities->settings->abap editor->debugging
check the check box (actv) in external debuggin box
hit enter and come out. now in the do_handle_event method place the cursor where you want to the break point and click the red icon with letters STOP, this will throw a popup asking whether you want HTTP break point or session break point , click the button HTTP break point.
Regards
Raja
But the problem is, it doesn't return the name of the form(this.form). That is why my variable myForm is null.
My view is a fragment only of a whole page. The <htmlb: form> tag is not included in the view. That is why I cannot access the name of the form. And so, I got a null value on line :
document.myForm.customVal
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a view that contains the following code:
<script defer language="Javascript" >
function text_edit(defaultSelected,defaultValue,myForm){
if (selectedText == ""){
selectedText = defaultSelected;
selectedValue = defaultValue;
}
customTextObject.cSelected = selectedText;
customTextObject.cValue = selectedValue;
textEditURL = "TextEdit.htm?option=" + selectedText + "&value=" + selectedValue;
customValue = window.showModalDialog(textEditURL,customTextObject,customPageFeatures);
var x = document.getElementById('customVal');
x.value = customValue;
<script>
.....
<htmlb:inputField id = "customVal"
visible = "FALSE"
value = "<%=lv_customvalue%>"/>
<htmlb:button text = "Edit"
onClientClick = "text_edit('<%=lv_selection%>','<%=lv_selectionvalue%>',this.form)"/>
As you can see, the button <b>Edit</b> calls the javascript function <b>text_edit</b>. This function opens a BSP page
named <b>TextEdit.htm</b>. Here are the contents of TextEdit.htm:
<script language="javascript">
function getValue(Cvalue){
window.returnValue = Cvalue
window.close();
}
</script>
...
<htmlb:form id="customTextForm">
<htmlb:textEdit id= "customTextArea" rows = "20" cols = "50" text=" "/>
<htmlb:button id ="create_text" text ="Create Text" width = "50" onClientClick="getValue(customTextForm.customTextArea.value)"/>
</htmlb:form>
My problem is how can I put the text entered by user to an ABAP variable.
My options are:
a) Process the data(through BAPI call) before the pop-up window is closed.
or
b)Since the data is passed back to my view through the javascript variable
customValue(the one returened by the modal dialog),
I can do the processing(through BAPI call) in the view, after the pop-up modal window is closed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Define a hidden input field on your view.
set its value to to the value that is returned by page(model page).
like
-
<script defer language="Javascript" >
function text_edit(defaultSelected,defaultValue,myForm){
if (selectedText == ""){
selectedText = defaultSelected;
selectedValue = defaultValue;
}
customTextObject.cSelected = selectedText;
customTextObject.cValue = selectedValue;
textEditURL = "TextEdit.htm?option=" + selectedText + "&value=" + selectedValue;
customValue = window.showModalDialog(textEditURL,customTextObject,customPageFeatures);
document.myForm.if01.value = customValue;
//this will forcibly submit the form
document.myForm.submit();
<script>
-
hidden field on page layout---
<htmlb:inputField id = "if01"
type = "string"
visible = "false"
size = "20" />
-
now at server acces the value of inputfield which contains the text entered by user.
if you do not submit the form then you can access and set your abap variable whenever there is a round trip to server.
rgrds,
hi Hemendra,
I wanted to ask you, on your post you state: "now at server acces the value of inputfield which contains the text entered by user.
if you do not submit the form then you can access and set your abap variable whenever there is a round trip to server." can you please indicate how this is achieved? Pardon me, I am new to ABAB programming.
Thanks,
Chris
But the problem is my BSP page is a modal pop-up window, when an event is triggered, a new explorer window will be opened. How will I handle this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!
Actually, this view calls a BSP page, I used a javascript to open it in pop-up window (window.showModalDialog). My first option is to put the processing in the view but then based from your reply, I was thinking of processing it in the BSP page(and not in the view which is the calling page). So after submitting the BSP page, I want to call a BAPI, how can I do that? Will I put my call to BAPI in the OnDestroy method?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
its not possible to assign js variable value to abap var.
however viceversa is possible.
you have to go for server round trip.
do this.
create an hidden input field assign js var value to it go to server round trip and retreive value.
check this sample code for this:
<SCRIPT language="JavaScript">
function func(){var txt;txt = "Hello";
document.formBody.if01.value = txt;
document.formBody.submit();
}
</SCRIPT>
<htmlb:form id="formBody" >
<htmlb:inputField id = "if01"
type = "string"
visible = "false"
size = "20" />
here we r assigning value of js var to inputfield and at server event handlling
get the value and assign it to abap var.
regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
61 | |
11 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.