#button won't button

39 messages · Page 1 of 1 (latest)

rustic sail
#

Does anyone know why my button refuses to button? When I click it, nothing happens at all. It was working before I added the form.

https://pastebin.com/tMbERL6r

odd kiln
#

if it's a form, the form is being submitted.

#

(or just change the type of your button to "button")

rustic sail
#

I'm currently trying to use a button outside the form to submit everything. so it's not a submit button. and i need to do this bc i also need the same button to redirect to a flask route.

#

also when i did have it as a submit button in the form, i could see the GET request in the console. now nothing happens. it doesn't submit OR do the function it's connected to.

worn parcelBOT
#

Never use var. It is outdated and dangerous. Instead, use const or let if you have to reassign.

odd kiln
#

Stop using var, jQuery, and window.onload

rustic sail
#

Ok I get var.. but how do I avoid using the other 2?

#

Also is that really on topic to my question? I don't think either of those 2 other things are messing with the button considering it was working before.

umbral vapor
#

Well jQuery and window.onload have been useless for about 15 years

rustic sail
#

That still doesn't answer any of my questions

umbral vapor
#

getElementByName doesn't exist

rustic sail
#

I'm not on that yet. I haven't even been able to test that function because the button doesn't work

umbral vapor
#

It doesn't work because your code errors

#

it errors because .getElementByName doesn't exist so it calls an unknown function and crashes your entire script

rustic sail
#

But it's not throwing an error

#

It just doesn't click

umbral vapor
#

.getElementsByName (plural) is a function that returns a collection which would also not work

rustic sail
#

It never gets to that

umbral vapor
#

Do the button and form get added to your body?

rustic sail
#

Yes

umbral vapor
#

works for me

#

it errors on getElementByName as said

rustic sail
#

Well it's not for me.. the button just doesn't click and so an error is never thrown

umbral vapor
#

What's your current code then?

rustic sail
#

I'm not sure what you mean

umbral vapor
#

I copy pasted your bin and when I click the button, it appropriately errors and does nothing more

#

I obviously removed the onload part since it was useless

#

probably that was the issue?

rustic sail
#

I don't think thats the problem bc, like I said, it was working before I added the forms

#

So the js will just start when the file is loaded.. right? Is that why onload is useless?

umbral vapor
#

Does your URL hash have an actual value? Maybe parsing the params is where it errors

rustic sail
#

Yes, it gets passed from the website I'm making an extension for.

umbral vapor
#

How involved is the extension? If it's "just" a bit of JS you can make it a userscript instead

rustic sail
#

That's pretty much the extent of the js i think. Everything else will be handled with flask.

#

Do you think it could be an issue with the browser? My friend was telling me about how Firefox has some quirks that break buttons sometimes. But I'm not at home so I can't test that.

umbral vapor
#

I am on Firefox, so, unlikely