Re: Problem w/ Hidden Input Fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Ferguson wrote:
Jochem,

Thanks for the response. I actually solved the problem a few days
ago... I'm suprised this message never went out to the list until
today.

I actually WANTED one to override the other in this case. The user
should be able to choose one of the default radio buttons (in which
case the hidden field would work) or be able to provide their own by
typing/pasting it into the text box.

I see - then I recommend that you reNAME both elements to 'txtKeyValue[]'.
this will cause php to create an array for you so you can always get to
both values. e.g.

print_r($_POST['txtKeyValue']); // Array

that will give you a numerically indexed array, if you rename the textboxes
individually to 'txtKeyValue[default]' and 'txtKeyValue[other]'
you will have an associative array with a structure like:

$arr = array(
	'default' 	=> 'ABQIAAAAh2cCTTmAE6T4OXjecIFe5BQMxb4e6BwgeSB7cBu9SbVQSak6ARTgAPoctbx36BXXgbYZONZls0B1LQ',
	'other' 	=> '',
);

there is no intrisic need to give the elements an id at all (regardless
never give 2 elements on one page the same id.)


I got around the problem by temporarily using a rather ugly switch
statement until I revist the problem in a later release.

I like switch statements, my favorite is the rather evil use
of switch()'ing on true:

switch (true) {
	case (/* arbitrary boolean expression */):
		break;
	// .. and so on
}


Jason

On 10/10/05, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:

hi Jason,

Jason Ferguson wrote:

I have a <input type="hidden"> field with a value 86 characters long.
Here is the entire form:

             <form name="frmWizard" id="frmWizard" method="post" action="">
                     <table>
                             <tr>

                                     <td><input type="radio" name="radioKey" value="2"
checked="checked" />Rootsweb
                                             <input type="hidden" name="txtKeyValue" id="txtKeyValue"
maxlength="90" value="ABQIAAAAh2cCTTmAE6T4OXjecIFe5BQMxb4e6BwgeSB7cBu9SbVQSak6ARTgAPoctbx36BXXgbYZONZls0B1LQ"
/>
                                     </td>
                             </tr>
                             <tr>
                                     <td><input type="radio" name="radioKey" value="2" />Other Site:
<input type="text" name="txtKeyValue" id="txtKeyOther" /></td>

this text input has the same name, seeing as it comes after the
hidden field it will be submitted after it (in terms of the order
of the POST vars) too. the value of second incoming txtKeyValue
effectively overwrites the first - result is you always see an empty value.

after thought:
you can work around it with javascript or php (and possibly changing
'txtKeyValue' to 'txtKeyValue[]'), or just change the name of
one of the fields :-)


                             </tr>
                             <tr>
                                     <td class="center">

                                             <input type="button" name="btnGenTemplate" id="btnGenTemplate"
value="Generate HTML" onclick="setWizardAction('genHTML.php')" />
                                     </td>
                             <tr>
                                     <td class="center">
                                             <input type="button" name="btnPrev" id="btnPrev" value="&lt;--
Prev" disabled="true" />
                                             <input type="button" name="btnNext" id="btnNext" value="Next
--&gt;" onclick="setWizardAction('mmwizard1.php')"/>
                                             <input type="button" name="btnFinish" id="btnFinish" value =" Finish" />
                                     </td>
                             </tr>

                     </table>
             </form>

However, when I submit and do a print_r($_POST), there is no value for
$_POST['txtKeyValue'].

Note: the setWizardAction() function sets the <form action="">
attribute so the Prev/Next buttons work correctly.

The application is very close to being complete, so I need help ASAP

don't quite follow that logic ;-)

.

Jason




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux