/    Sign up×
Community /Pin to ProfileBookmark

I’m a noob and in need of some help

Hello Everyone,

I’m a survey programmer working with a third party proprietary survey tool and have very little experience with JavaScript. I’m attempting to create a script that will simulate an Interviewer going through a survey (essentially an “autopilot” of sorts to test out server loads and questionnaire functionality). I’m doing this by simulating the clicking of radio buttons and form submission after a setTimeout.

What I wanted to do was take a unique piece of information provided in the Web interface and run some scripts based on if/then statements. Here are the pieces that seem to be needed and how they are presented in the back-end of the Web interface:

I need the value from this element:

[COLOR=”Red”]<INPUT TYPE=”HIDDEN” NAME=”RECNUMB” VALUE=”1140005790″>[/COLOR]

I don’t know why the creators of this program don’t use ID tags, but they don’t. As such, my coworker suggested I use the following to get that value:

[COLOR=”red”]var respondent = setTimeout(alert(“document.forms[0].elements[‘RECNUMB’].value”),500);[/COLOR]

This leads to another strange caveat of the program. It seems that it does not like performing functions that are NOT part of setTimeout. The reason we used alert was to see if the RECNUMB would be returned (which it is), but I’m having trouble from that point. Here is the rest of the script:

[COLOR=”red”]if (respondent >= 1100000000 && respondent <= 1200000000)
{
setTimeout(“document.getElementById(‘SC_NOCON_01’).click();”,5000);
}
else if (respondent >= 1200000001 && respondent <= 1300000000)
{
setTimeout(“document.getElementById(‘SC_NOCON_02’).click();”,5000);
}
else
{
setTimeout(“document.getElementById(‘SC_NOCON_03’).click();”,5000);
}
[/COLOR]

Everything I’ve been trying gives me errors, typically ones saying that “document.forms[0].elements[‘RECNUMB’].value is null.” My coworker suggested using parseInt to change the RECNUMB string to an integer, but I’m still having problems.

Since it seems that this program doesn’t use conventional syntax, I may just be stuck with trial and error for a while, but I thought the members of this forum might be able to shed some light on the issue. I very well may have this all wrong from the start.

Thank you for your help!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mtngpeopleisezauthorOct 13.2011 — Next time I'll use a more descriptive heading and the vB blocks.
×

Success!

Help @mtngpeopleisez 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.24,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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