/    Sign up×
Community /Pin to ProfileBookmark

looping thru inputs

I have an xml file and it has some elements that have an attribute called answercontrol, if this is true I want to go into it.
In IE i have it working but not in mozilla.

The code starts like this:

[code]
function fnBuildAnswersXML(doc)
{
var allinputs = doc.getElementsByTagName(‘input’);
var xml = “<?xml version=”1.0″ encoding=”ISO-8859-1″?>”;
xml=xml+”<screen screenNumber=””+ screenNum +”” finalScreen=”false” totalNumberOfScreens=””+ totalNumScreens + “”>”
for(var i=0;i<allinputs.length;i++)
{
// loop through all answercontrols
alert(“CHECK -> allinputs[i].answercontrol = ” + allinputs[i].answercontrol)
if(allinputs[i].answercontrol==’true’)
{
[/code]

The alert always pops up an undefined. I really haven’t a clue what to do next.

Sniipe

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@yellabuffDec 11.2006 — Try using allinputs[i].getAttribute("answercontrol")
Copy linkTweet thisAlerts:
@A1ien51Dec 11.2006 — Look into getAttribute() and see if that helps.

Eric
Copy linkTweet thisAlerts:
@SniipeauthorDec 11.2006 — sweet, getting somewhere...

how would I convert this line tho

allSelects[i].options[allSelects[i].selectedIndex].value ??
Copy linkTweet thisAlerts:
@yellabuffDec 11.2006 — Convert it to what?
Copy linkTweet thisAlerts:
@SniipeauthorDec 11.2006 — its all good, thanks for your help lads:

allSelects[i].options[allSelects[i].selectedIndex].getAttribute("value")



I'll look into this tomorrow but if u have an answer to this (off-topic, I know)

I'm getting all the inputs from text boxes. The text boxes have defaults and when I enter a value in one it doesn't get the value from the following code:



allinputs[i].getAttribute("value")



perhaps value isn't recognised by mozilla, because it does work for IE.



note: allinputs[i] being a textbox
×

Success!

Help @Sniipe spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...