www.webdeveloper.com
Results 1 to 2 of 2

Thread: I'm a noob and in need of some help

  1. #1
    Join Date
    Oct 2011
    Posts
    2

    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:

    <INPUT TYPE="HIDDEN" NAME="RECNUMB" VALUE="1140005790">

    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:

    var respondent = setTimeout(alert("document.forms[0].elements['RECNUMB'].value"),500);

    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:

    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);
    }


    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!

  2. #2
    Join Date
    Oct 2011
    Posts
    2

    Also, sorry for the posting faux pas...

    Next time I'll use a more descriptive heading and the vB blocks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles