Here’s my current code:
$(document).ready(function(){
$("input#url").bind("textchange",showPage);
$("input#url").focus();
$("form#surlform").submit(function(){
var url = $("input#url").val();
$.get("api/create.php?url=" + url, function(data) {
$("input#url").val(data);
$("input#url").select();
});
return false;
});
});
$(document).click(function(){
showPage();
});
$(document).mousemove(function(){
showPage();
});
At the moment, when the form is submitted, jQuery stops it from reloading the page, and simply pulls the required output from the API.
If possible, I’d like to make it also change the button, so that the button text is different, and it links to a page instead of submitting the form with jQuery. (If it helps, the button it changes to can be a div – only the original button needs to be button for form).
That’s not all…
I’d then like it to change BACK to the button that submits the form via jQuery with the original text when the text in the text field is altered.
This is quite a big ask, but if anyone’s got a way to go about this, I’d be very grateful.
Something like this?:
HTML:
CSS:
JavaScript:
It’s overly simple at the moment and could likely use some improvement, but the idea is straightforward enough…
window.location = 'some new location';essentially.