0

I'm trying to get a few lines of code to click checkbox and button in a website. the elements on the website are shown as following:

<td>
    <label style="display: block; cursor: pointer">
        <input type=radio name="business_9942704" value="2"> Banking Now Inc.
    </label>
</td>

<input type="submit" value="Commit!">

So what it needs to do it click on the name "business_9942704" and then click on the value Commit!

I have tried multiple things but I'm not sure what am I doing wrong, my code looks like this:

document.getElementByName('business_9942704').click(); 
document.getElementByValue('Commit!').click();

What am I doing wrong?

Thanks in advance!

1

2 Answers 2

1

there is not a function getElementByName

but

getElementsByName

please take a look in the console to see errors, don't program in blind mode

Sign up to request clarification or add additional context in comments.

Comments

0

Correct method is document.getElementsByName('business_9942704')[0].click();

But this method return array of element you need use index for them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.