cancel
Showing results for 
Search instead for 
Did you mean: 

Field selection using javascript

Former Member
0 Kudos

Hi,

I am using htmlb and xhtmlb for my BSP page development, which has a tableView. The content design being used is design2003.

I am using the following javascript code to keep a field selected:

function changeFocus()

{

myForm.barcode.select();

}

myForm is the form name,

barcode is the inputField, within a tableView.

This works fine, when I am using the desing2002 or CLASSIC. But when I use the design2003, this does not work, but it only keeps the cursor focus on the inputfield. I want the entire value to be selected.

Any help in this would be highly appreciated.

Thanks

Shankar

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Give design attribute value as design2003+design2002 .

You will get the solution.

Regards,

Azaz Ali.

Former Member
0 Kudos

Hi,

I tried using design2003+design2002, but still it does not work.

Regards,

Shankar

Former Member
0 Kudos

Hi,

Add this is attribute for the content and try...

<htmlb:content forceEncode="enabled">

Regards,

Azaz Ali.

Former Member
0 Kudos

Hi,

I tried with the option forceEncode also, but it does not work.

Regards,

Shankar

Former Member
0 Kudos

Hi Shankar,

You do one thing send the layout code. it is difficult to answer where you have gone wrong without code.

Regards,

Azaz Ali.

Former Member
0 Kudos

Hi Azaz,

Foll is the layout:

<%@page language="abap" %>

<%@extension name="htmlb" prefix="htmlb" %>

<%@extension name="xhtmlb" prefix="xhtmlb" %>

<html>

<head>

<META HTTP-Equiv="Battery" content="Hide">

<META HTTP-Equiv="Signal" content="Hide">

<META HTTP-Equiv="Scanner" content="Enabled">

<META HTTP-Equiv="HomeKey" content="Enabled">

<SCRIPT LANGUAGE="JavaScript" SRC="utilities.js"></SCRIPT>

</head>

<htmlb:content design="classicdesign2002design2003"

forceEncode="ENABLED"

rtlAutoSwitch="true"

controlRendering="sap">

<htmlb:page title = "Receive Inventory"

onLoad = "javascript:changeFocus()" >

<script>

function changeFocus()

{

<% if lv_toggle = ' '. %>

myForm.barcode.focus();

<% else. %>

myForm.poqty_1_3.select();

myForm.poqty_1_3.focus();

<% endif. %>

}

</script>

<htmlb:form id="myForm" >

<%@include file="page_header.htm" %>

<table BGCOLOR="#cccccc" width="240px" cellspacing="0" cellpadding="0" border="0">

<td><b><%= otr(ZRETAIL_SYMBOL/RECEIVE_INVENTORY) %></b></td>

<td align="right"> <b>

<htmlb:link id="menu" text="<%= otr(ZRETAIL_SYMBOL/MENU) %>" onClick = "menu" />

</b>

</td>

</table>

<%@include file="status_bar.htm" %>

<br>

<% if not application->gv_vendor_type = 'RAC'. %>

<table width="240px" cellspacing="0" cellpadding="1">

<tr>

<td>

<htmlb:textView text="PO Document" />

</td>

<td>

<htmlb:inputField id = "po"

value = "<%= application->gv_po %>"

maxlength = "10"

disabled = "X"

/>

</td>

</tr>

</table>

<% endif. %>

<htmlb:tableView id = "poqty"

design = "STANDARD"

designMode = "HTMLB"

visibleRowCount = "4"

table = "<%= lt_items %>"

width = "240px"

tableLayout = "AUTO"

iterator = "<%= iterator %>"

>

</htmlb:tableView>

<htmlb:textView text="<%= otr(ZRETAIL_SYMBOL/BARCODE) %>" />

<htmlb:inputField id = "barcode"

value = "<%= lv_barcode %>"

submitOnEnter = "X"/>

<br>

<xhtmlb:protectDoubleSubmit/>

<htmlb:button id = "post"

text = "Post"

width = "60px"

onClick = "post"/>

</htmlb:form>

</htmlb:page>

</htmlb:content>

Regards,

Shankar

athavanraja
Active Contributor
0 Kudos

check this code sample. it works with all designs (2003, 2002, classic)

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>

<htmlb:content design="design2003">
  <htmlb:page title = " " onLoad="textFocus();">
    <htmlb:form id="myform">
<%
data: test type string .
test = 'Selected' .
%>
       <htmlb:inputField id         = "IP1"
                        alignment  = "LEFT"
                        size       = "10"
                        type       = "STRING"
                        value      = "<%= test %>" />
                        
<SCRIPT LANGUAGE="JScript">                        
function textFocus()
    {
    document.myform.IP1.select();
//        document.getElementsByName("IP1")[0].select();    
    }
</SCRIPT>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

in the javascript function textFocus

both the approach works

you can use

document.myform.IP1.select();

or this also

document.getElementsByName("IP1")[0].select();

Regards

Raja