Jump to content

Code to retrieve values from a form?


Dan06

Recommended Posts

I'm new to Javascript. I was trying to retrieve values from a form and I used the following code.

var x = document.form['formName'].element['fieldName'].value;

 

That didn't work, so I tried another way; I used the code below.

var x = document.getElementById('formName').fieldName.value; 

This code worked.

 

Can someone tell me where I went wrong with the first attempt/code? Thanks.

Link to comment
https://forums.phpfreaks.com/topic/131377-code-to-retrieve-values-from-a-form/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.