View Full Version : [object HTMLInputElement]

10-13-2006, 09:01 PM
Attempting to pass the value of a Javascript variable to a PHP variable.
The input field named MajorEdit3 does dynamically load a value based upon the user's listbox selection. It is that value which needs to be passed to the PHP variable.
The receiving page keeps returning the following:

[object HTMLInputElement]

So it recognizes there is data but it's failing to completely handle the request.
Anyone see what I'm missing here?

Sending page:

<input type="text" name="MajorEdit3" id="MajorEdit3" size="3">
var MajorRecords = document.getElementById("MajorEdit3");
document.write("<a href=\"DBEditMajor.php?record="+MajorRecords+"\"><input disabled type='submit' value='Save revisions' name='MajorRev' id='MajorRev' title='Store Major revisions' resolveData()></a>");

echo $_GET['record'];

10-14-2006, 02:25 AM
the getElementById function, surprisingly enough, returns an element, not a value.
add .value to the end to get the value...

10-14-2006, 02:46 AM
the getElementById function, surprisingly enough, returns an element, not a value.
add .value to the end to get the value...
Actually, it gets a DOM representation, an "object" (Document Object Model) of the element. The actual element name is stored in document.getElementById("MajorEdit3").nodeName

It could also be stored in tagName, name and localName (Firefox has so many ways to show it). nodeName should work in almost any browser that supports DOM scripting. AFAIK, IE6, Fx and Opera do support it.

10-16-2006, 08:45 PM
Adjusted the code to

var MajorRecords = document.getElementById("MajorEdit3").nodeName;

Now I'm getting "INPUT" instead of "[object HTMLInputElement]".


What I'm trying to collect is the contents of the following input box:
<input type="text" name="MajorEdit3" id="MajorEdit3" size="3">

10-16-2006, 11:06 PM
It seems rpgfan has managed to confuse you.

returns the element with id 'something'.

suffixing '.nodeName', as it would suggest, returns the name of the node that is the element, in your case 'input'.

suffixing '.value' instead, again unsurprisingly, returns the 'value' attribute of the element; that is (for an input), whatever is present in the field.

10-17-2006, 04:06 PM

Swapped nodeName for nodeValue.

Now I'm seeing accurate info in the status bar.


Working to get the current field value to replace "null".

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum