cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving the Element id

Former Member
0 Kudos

Hi All,

Im trying to use client data bag..,for achieving this I want to get the id of elements say,inputfield in javascript..how should i get the id..any idea...if anyone tried out client data bag in .net give me an idea for achieving this..

Regards,

Vinoth

Message was edited by: Vinoth M

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ofer,

This is my code..

<body class="prtlBody" xmlns:sap="urn:http://schemas.sap.com/SAP.Web.UI.Controls">

<script language="JavaScript">

var data = "";

function go(){

var funcName = <%=Form.id "."InputFieldChild.ClientID %>;

alert(funcName)

}

</script>

<form id="form1">

<table>

<tr width="100%">

<td width="100%"><sap:textview id="TextViewChild" Visibility="VISIBLE" Text="Enter Value:" Design="HEADER1" Runat="server"></sap:textview>

<sap:inputfield id="InputFieldChild" Visibility="VISIBLE" Runat="server" Value=""></sap:inputfield>

</td>

</tr>

<tr width="100%">

<td width="100%">

<sap:Button ID="ButtonChild" Runat="server" Text="StoreData" Design="EMPHASIZED" Visibility="VISIBLE"

BUTTONCLICK="javascript:go();"></sap:Button></td>

</tr>

</table>

</form>

</body>

im getting the output in alert for funName as [object].

Am i missing something..??could u tel me where am i make the necessary change..

Regards,

Vinoth

Former Member
0 Kudos

Hi Vinoth,

If I'm not mistaken, you get "[object]" since that is what you have in "funcName"... an object - the HTML object created from InputFieldChild. You can use it's html properties, like "value", "readonly", "onmouseover" etc'.

Regards,

Ofer

Former Member
0 Kudos

Hi Ofer,

No, i didnt tried control.clientid yet ..could u tel me the syntax for tht..

regards,

Vinoth

Former Member
0 Kudos

Well, it depends on what you are trying to do, but this is server coed, meaning it's C# code... you can look it up in the help, but essentially it's a property of all controls called "ClientID". In ASP controls (and SAP controls) it will hold the ID that will be rendered to html. I'm guessing you have some JS which is doing something. So it should look like something like this:


<SCRIPT language ="JavaScript"> 
function doSearch(id, e) 
{ 	
 var myControlID=<%= Form.ID+"."+myControl.ClientID %>;
 ... 
}
</SCRIPT>

Regards,

Ofer

Former Member
0 Kudos

Hi Vinoth,

Did you try writing to your Script the property Contorl.ClientID?

Regards,

Ofer