473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

javascript finding an element with the text befor the element

is there any methode to find an element like in this is example:
Element <input type="text" />
for example if i want to be able to change the value of the input after the text "Element" , is that possible , without nowing the name or the id of the input . thank's for help.
Nov 8 '13 #1
3 1273
bomb23
2
hi ,
it is possible , but you must know number of your input tags in your html document, for example:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <input type="text" />
  3. <input type="text" />
  4. <input type="text" />
  5. </html>
  6.  
  7. <script>
  8. var firstInput = document.getElementsByTagName('input')[0];
  9. </script>
  10.  
this code get you first input and if change the 0 to 1 you will have the Second input and ...
good lock
Nov 12 '13 #2
Dormilich
8,658 Expert Mod 8TB
for example if i want to be able to change the value of the input after the text "Element" , is that possible
no. or at least not without a fulltext search.

HTML is a markup language that bases its information on tags, hence you have very efficient access algorithms when it comes to tags. text however is not part of any HTML structure and therefore it’s way more difficult to find an arbitrary piece of text than an arbitrary element.
Nov 12 '13 #3
9815402440
180 100+
value can be changed as suggested by bomb23 but this approach is not reliable. because tag-numbers are generated on compile and this number may vary if new elements are added or deleted. you can change value by tag-number if you know the name or id of the control that lies immediately after or previous the target control. then tag-number can be calculated by adding or deducting 1 from the tag-number of control that lies after or previous the target control. literally it is impossible to change the value without knowing name or id

Best wishes
Manpreet Singh Dhillon
Nov 12 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Y.S. | last post by:
Hello All, I have the following schema: .... <xs:element name="data_type_id" type="xs:unsignedShort" /> <xs:element name="data_value" type="xs:anyType" /> .... What I want to do is to...
0
by: sat | last post by:
Hi, I am facing problem while finding a text (Ctrl + F). In a Web Application, data is displayed in grid form and the left column is locked in the display. when i try to search for a text...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
3
by: Robert Oschler | last post by:
What's a good way to find a specific text node element in a web page's DOM tree? I thought of traversing each node but there has to be a faster way. Is there a "find text node by nodeValue"...
1
by: Lena | last post by:
I have generated a proxy class derived from System.Web.Services.Protocols.SoapHttpClientProtocol One of my classes is defined as public class MyClass { public MyClass() {
1
by: Nathan Alden | last post by:
I have an XSD defined as the following: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"...
6
by: ste.paoletti | last post by:
hi, I have read that browsers support block element inside inline element but the css is not valid. Someone can tell me more about? What do you think? Thanks.
5
by: felipevaldez | last post by:
how can I put an element below another element, that's not absolutely positioned? so I have a n element, called X, and next to that, an element Y X Y XXXXXX
1
by: Tor Inge Rislaa | last post by:
Finding Bold Text (or other formatting attributes) in RichTextbox . Is it possible to find and select bold text by code within the text of a RichTextbox? What I want is to manipulate the text...
1
by: jerico | last post by:
Hi, I am a beginner in xml.I am puzzled about the difference between global element and root element.Any explanation would be greatly appreciated. Jerico
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.