JQuery - find dynamic id value

OK, so I use the CRM system on demand, and the URL should be updated when the form is updated. For some reason, the form cannot be specified by identifier, so I need another way to get value = "THIS".

No identifiers allowed! (If you do not know why) Thank you :)

Relevant HTML:

<input id="ServiceRequestEditForm.CustomObject6 Id" class="inputControlFlexWidth" type="text" value="THIS CHANGES AFTER UPDATE" tabindex="9" size="25" name="ServiceRequestEditForm.CustomObject6 Name"> 

Thanks for the quick answers. The reason I could not select the identifier was because it contained a complete revolution. For instance. EditForm.CustomObject6 should become EditForm \ .CustomObject6

The answers are still very helpful.

+4
source share
4 answers

You can use custom attributes.

 <script> var value = $("input[custom=custom]").attr("value"); </script> <input custom="CUSTOM" id="your thing" class"blah blah" type="text" value="VALUE" tabindex="9" size="25" name="blah blah"> 
0
source
 <input id="blah" onchange="javascript: MyOnChange(this);"> <script> function MyOnChange(myControl) { alert(myControl.id); } </script> 
0
source

IDs and NAMEs must begin with a letter ([A-Za-z]) and can be followed by any number of letters, numbers ([0-9]), hyphen ("-"), underscore ("_"), colons (":") and periods (".").

No space allowed, your identifier is invalid.

0
source

If the only problem is this . in ID, you can do something like:

 var field = $("input[id='full.ID.here']"); 

.

If the identifier contains some dynamic parts that always change, but one part of it is constant:

 var field = $("input[id*='ID part here']"); 

Pay attention to *= .

.

If the known part of the identifier is, in particular, at the end, you can use:

 var field = $("input[id$='ID part here']"); 

Pay attention to $= .

.

For a complete reference to the jQuery selector, check:

http://api.jquery.com/category/selectors/

0
source

All Articles