473,609 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript finding an element with the text befor the element

1 New Member
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 1278
bomb23
2 New Member
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 Recognized Expert Moderator Expert
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 New Member
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
2090
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 specify that "If 'data_value' element exists, 'data_type_id' element MUST exist".
0
935
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 by opening Find window (Ctrl + F) on the page, it searches fine. But if i keep pressing the Find Next button ( it is fine until cursor reaches the end of the page) then the
19
6871
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 JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
3
5501
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" function or something? I do know the nodeValue (text string) of the text node. Thanks.
1
1780
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
356
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" attributeFormDefault="unqualified"> <xs:element name="Application"> <xs:complexType> <xs:sequence> <xs:element name="ReceivedDate" type="xs:string"/> </xs:sequence>
6
787
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
3989
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
3119
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 into HTML code. Replace the Bold text with <b>This is the bold text</bbefore I save it to an HTML file.
1
4095
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
8139
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8091
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8555
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7024
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6064
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5524
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.