getelementsbyname

javascript, getelementbyname and focus

て烟熏妆下的殇ゞ 提交于 2019-12-04 09:54:20
I am trying to create function that will look at the username if it is not valid send an alert to the user, clear the username field, and put the username field back into focus. I am trying to do this all with the getElementsBynName() function. It is all working with the exception of getting the field back into focus. My code is below. Does anyone have any suggestions. function uchecker(uname) { var validUname = uname.search(/^\w+@sabc.com$/); if(validUname != 0) { alert("You have entered an invalid username. \n The username must be a valid @sju.edu email address value " + document

GetElementsByName with array like name

流过昼夜 提交于 2019-12-04 09:03:22
i often use this notation when i name my controls in order to get an array in POST or GET. <input name="color[1]" type="text" /> <input name="color[2]" type="text" /> <input name="color[3]" type="text" /> so in my scripts i can do <?php $data=$_GET["color"]; for each ($color as $key=>$value) { doSomething(); } ?> Often happens that i need to get those id back in javascript , but i cannot get them , so i often add an ID to each element in html like that <input name="color[3]" id="color_3" type="text" /> so that i can use document.getElementsById('color_3') Instead i would like to find way to

javascript loop only applying to every other element

核能气质少年 提交于 2019-12-04 04:17:02
问题 i have the following javascript below after i finish an ajax query all of my images have name="pic" <script type="text/javascript"> function done() { var e = document.getElementsByName("pic"); alert(e.length); for (var i = 0; i < e.length; i++) { cvi_instant.add(e[i], { shadow: 75, shade: 10 }); } } my goal is to apply an image border around using this library: http://www.netzgesta.de/instant/ the problem is that for some reason this works but it only seem to apply to every other picture

javascript loop only applying to every other element

爷,独闯天下 提交于 2019-12-01 21:01:45
i have the following javascript below after i finish an ajax query all of my images have name="pic" <script type="text/javascript"> function done() { var e = document.getElementsByName("pic"); alert(e.length); for (var i = 0; i < e.length; i++) { cvi_instant.add(e[i], { shadow: 75, shade: 10 }); } } my goal is to apply an image border around using this library: http://www.netzgesta.de/instant/ the problem is that for some reason this works but it only seem to apply to every other picture instead of every one. any clue why the code above would skip every other element?? EDIT: I added an alert

C# get element by name

北城余情 提交于 2019-11-29 14:50:14
Soo ive figured out how to get element by id, but i dont know how i can get element by name Here is my code: private void SendData() { webBrowser1.Document.GetElementById("textfield1").SetAttribute("value", textBox1.Text); webBrowser1.Document.GetElementById("textfield2").SetAttribute("value", textBox1.Text); } The problem is in my html code only textfield1 is a id but textfield2 is name soo i want to figure out how to get textfield2 Here is my html code: <html> <input type="text" id="textfield1" value="TEXT1"><br> <input type="text" name="textfield2" value="TEXT2"><br> <input type="submit"

On IE document.getElementsByName won't work

我怕爱的太早我们不能终老 提交于 2019-11-28 11:17:09
I use this code: <div name="1234"> <img src="pic.gif" height="70" width="100" onMouseOver="clear('1234')"> </div> And: function clear(element_name){ document.getElementsByName(element_name)[0].innerHTML=""; } It does work in Firefox and Opera, but doesn't work in IE 6.0 or IE 8.0, and probably not even in newer IE's. What to do? Well, the problem is this: IE understands document.getElementsByName(...)[0] as document.getElementById(...). So if you would define also an id for your element, the method document.getElementsByName(element_name)[0].innerHTML="" will surprisingly also work in IE! But

C# get element by name

落花浮王杯 提交于 2019-11-28 08:18:39
问题 Soo ive figured out how to get element by id, but i dont know how i can get element by name Here is my code: private void SendData() { webBrowser1.Document.GetElementById("textfield1").SetAttribute("value", textBox1.Text); webBrowser1.Document.GetElementById("textfield2").SetAttribute("value", textBox1.Text); } The problem is in my html code only textfield1 is a id but textfield2 is name soo i want to figure out how to get textfield2 Here is my html code: <html> <input type="text" id=

Javascript: setAttribute() v.s. element.attribute = value to set “name” attribute

蹲街弑〆低调 提交于 2019-11-27 14:42:50
So I'm learning to manipulate the DOM and I noticed one interesting thing: Let's say I want to set the name attribute of an element by using the "." dot notation: element.name = "someName"; console.log(document.getElementsByName("someName")[0]); // returns "undefined"?? However if I use the document.setAttribute() method, it works fine: element.setAttribute("name", "someName"); console.log(document.getElementsByName("someName")[0]); // returns the element like it should. Not sure why the dot notation method doesn't work in the first case. Why does this happen? My guess (because you didn't

CasperJS passing variable to evaluate can't get it to work [duplicate]

前提是你 提交于 2019-11-27 08:12:21
问题 This question already has an answer here: Passing variable into page.evaluate - PhantomJS 3 answers okay so here's my casperjs function : if(casper.exists(ac2)){ var accountnumber = this.fetchText('div.arabic:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2) > a:nth-child(1)'); var redir = accountnumber.substr(1); casper.then(function() { var uel = "https://example.ws/send.html?f=" + redir; this.thenOpen(uel, function() { casper.wait(10000, function()

Get attribute by name

混江龙づ霸主 提交于 2019-11-27 05:20:40
I have a struct definition with about 25 elements struct X { field 1; field 2; .. }; and I'm trying to fill it with some map values Map<String,String> A and it appears to be very annoying to do such thing n times X->xx = A["aaa"] every time that I want to fill my message struct. Is it possible to access the members by name, e.g. X->get_instance_of("xx").set(A["aaa"]); and put it into a loop? C++ lacks built-in reflection capabilities of more dynamic languages, so you cannot do what you would like using he out of the box capabilities of the language. However, if all members are of the same type