Sto cercando di intercettare l'invio di un modulo per modificare il valore della mia etichetta keywords
.Impossibile `submit()` un modulo html dopo aver intercettato l'invio con javascript
ho il seguente codice:
<HTML>
<FORM name="searchForm" method="get" action="tmp.html" >
<input type="text" name="keywords" />
<input type="button" name="submit" value="submit" onclick="formIntercept();"/>
</FORM>
<SCRIPT language="JavaScript">
document.searchForm.keywords.focus();
function formIntercept() {
var f = document.forms['searchForm'];
f.keywords.value = 'boo';
f.submit();
};
</SCRIPT>
</HTML>
Quando ho eseguito questo in cromo e fare clic sul cambiamenti parole chiave etichetta pulsante di invio per boo
, ma la console javascript dice:
Uncaught TypeError: Property 'submit' of object <#an HtmlFormElement> is not a function.
Come può Invio il modulo con le parole chiave manipolate?
Che cosa è un 'o più specificamente, cosa intendevi veramente inserire nell'attributo type? –
oops. hai ragione. cambiando 'type =" label "' a 'type =" text "' –