Jump to content

Change Form values with JS


alternative

Recommended Posts

Hello, Suppose we have a form<form id="form1" class="form" method="post" action=".." enctype="application/x-www-form-urlencoded"> <input type="text" id="usr" name="usrname" value="" /> <input type="password" id="passwordTf_field" name="passwordTf_field" value="" /> <input id="loginBtn" type="submit" name="loginBtn" " /></form>I want to create an extension that will add a javascript function that will change the onclick action, so when the user press the submit button,the values of the username and password will be changed and then the form will be submitted.I have made the extension and all the changes but when I submit the form through the javascript function, nothing happens.This is my scriptfunction changeLogin() { var x=document.getElementById('usr'); x.value = somethinh document.forms["form1"].submit(); }The changes are applied but the problem is that the form with the new and changed data are not submitted. I use firefoxThanks for any replies

Link to comment
Share on other sites

if you want to access a element by id you need to use document.getElementByID("form1") the 'form' collection of a document will return the numerical array of the all form element.

Link to comment
Share on other sites

if you want to access a element by id you need to use document.getElementByID("form1") the 'form' collection of a document will return the numerical array of the all form element.
thanks for the reply, I change the values, but then I cant submit the form with the new values
Link to comment
Share on other sites

can you show us the updated code?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...