Xerxes wrote:
I am trying to pass the value of a field to a PHP file like this:
<input type="hidden" name="field1" id="field1" value="123">
<input type="hidden" name="field2" id="field2" value="456">
<a href =
"test.php?c1=do cument.getEleme ntById('field1' ).value&c2=docu ment.getElement ById('field2'). value
<img src="add.gif" border="0"></a>
In test.php, when I do:
c1=$_GET['c1'] ;
echo c1;
I get:
c1 = document.getEle mentById(\'fiel d1\').
Of course. It is rather astounding that you get anything at all, since
the attribute value is not Valid (it has not been properly delimited.
The value of the `href' attribute is specified to be URI reference.
Script data is not evaluated in URIs references automatically. However,
you do not need any script code or IDs here:
<form action="test.ph p">
<div>
<input type="hidden" name="c1" value="123">
<input type="hidden" name="c2" value="456">
<button><img src="add.gif" alt="Add" border="0"></button>
</div>
</form>
You should be aware that this works in HTML 4-compliant user agents only
because of the `button' element.
<URL:http://www.w3.org/TR/html4/interact/forms.html#edef-BUTTON>
HTH
PointedEars