html - Stop Javascript Function From Refreshing Page -
html - Stop Javascript Function From Refreshing Page -
when run js function (on button click) reloads page , displays info function outputs. however, when run js code when page loads (no function or button) script runs fine.
i have tried multiple things prepare issue such using button type="button" instead of input. tried have js function homecoming false. problem is, not have access js , can implement it, not alter it.
js code without function:
var placeholder = new sched({ pid: "something" }); placeholder.write();
when had button (with type="button"), removing placeholder.write() line stop page reloading, prevent js doing job. take html produced placeholder.write() , add together div. know how static data, cannot prevent page reloading , displaying nil placeholder.write() prints.
if need more concise, allow me know. had problem trying figure out how phrase question...
edit: wanted add together info overall project. i'm making page university. school provides page builder allows html input. site takes html want , adds university's website layout (such side bar, header , footer).
the user should able come in major's code input box, click button, , course of study info should appear below. i've simplified in testing figure out why page reloading (also when button pressed, university's website's layout lost). in simplification, i've removed input , form , have button runs function containing above code. "something" replaced major's code (statically). i've tried setting placeholder.write() div's innerhtml did not work either.
if button in form, automiticaly submits, while click it. need run preventdefault()
method on event
object or return false
function.
you may want here: how prevent form beingness submitted?
javascript html
Comments
Post a Comment