Page 1 of 1

Text Field changes to 'True' on click - and won't pass Var

Posted: Wed Feb 04, 2015 9:33 am
by simonmlewis
I have an odd form.

Code: Select all

<form method='post' action='/a_productedit'>
			<input type='text' name='id' value='2662'>
			<input type='submit' value='Edit 2662'>
			</form>
I'm using "text" instead of hidden just to see the id. But if I click Edit, that field changes to "true" for a split second, and posts "true" to the next page.

Is there a common cause for this? There is no ajax on this page to cause such a change.

Re: Text Field changes to 'True' on click - and won't pass V

Posted: Wed Feb 04, 2015 9:40 am
by Celauran
Nothing in the code you have posted explains that behaviour. What else is interacting with the form?

Re: Text Field changes to 'True' on click - and won't pass V

Posted: Wed Feb 04, 2015 9:46 am
by simonmlewis
Nothing. There are no other <form> tags before it. All the <a href> tags have the correct apostrophies and closing </a> tags.

The really odd this is how it changes in the field. Click it... it goes from numeric to the word "true" instantly.

If I put another form above this code, my code works, but then the new code has the same problem, with "true" going in there. Goodness knows why.

Re: Text Field changes to 'True' on click - and won't pass V

Posted: Wed Feb 04, 2015 9:49 am
by simonmlewis
Damn it, it's this code here:

Code: Select all

    <script type = "text/javascript">
        function Select(obj) {
            obj.className = 'selected';
            obj.getElementsByTagName("input")[0].value = "true";
        }
        function HighLight(obj) {
            if (obj.getElementsByTagName("input")[0].value == "false") {
                obj.className = 'highlight';
            }
        }
        function UnHighLight(obj) {
            if (obj.getElementsByTagName("input")[0].value == "false") {
                obj.className = '';
            }
        }
    </script>
When we click the row, it highlights (on purpose). But it's changing the value of a field too.
And it uses this to highlight the row:

Code: Select all

onclick=\"Select(this);\"

Re: Text Field changes to 'True' on click - and won't pass V

Posted: Wed Feb 04, 2015 9:54 am
by simonmlewis
I've changed the script to this:

Code: Select all

    <script type = "text/javascript">
        function Select(obj) {
            obj.className = 'selected';
            
        }
        function HighLight(obj) {
            if (obj.getElementsByTagName("input")[0].value == "false") {
                obj.className = 'highlight';
            }
        }
        function UnHighLight(obj) {
            if (obj.getElementsByTagName("input")[0].value == "false") {
                obj.className = '';
            }
        }
    </script>
Tho oddly, we use this elsewhere on other sites, and it works without flaw.

Re: Text Field changes to 'True' on click - and won't pass V

Posted: Wed Feb 04, 2015 9:55 am
by Celauran

Code: Select all

obj.getElementsByTagName("input")[0].value = "true";
You may want to refine this a little so it doesn't blindly grab the first input element. I don't know what the criteria should be, understandably, but perhaps adding a class to use as a selector would help.