How to get a text input value into a php script

T

Todor Vachkov

Dear all,

here is the code:
-----------------------------
<tr>
        <td>ohne Anmeldung: </td>
        <td><input name="vanm" id="vanm" type="checkbox"
onclick="DisableTeilnehmerzahl()"></td>
</tr>
<tr>
        <td>Max. Teilnehmerzahl: </td>

        said:
</tr>
-----------------------------
function DisableTeilnehmerzahl() {
        if (document.new_veranstaltung.vanm.checked == true) {
                document.new_veranstaltung.vteilz.disabled=true;
                document.new_veranstaltung.vteilz.value="0";
        } else {
                document.new_veranstaltung.vteilz.disabled=false;
                document.new_veranstaltung.vteilz.value="";
        }
}
-----------------------------
When the "vanm" checkbox is being checked the text input "vteilz" should be
deactivated and become the value 0. By sending the form parameters to a php
script I'm getting for the variable $_POST['vteilz'] NULL instead of 0.
Can someone help me?

Thanks in advance
 
J

Jeff North

| Dear all,
|
| here is the code:
| -----------------------------
| <tr>
|         <td>ohne Anmeldung: </td>
|         <td><input name="vanm" id="vanm" type="checkbox"
| onclick="DisableTeilnehmerzahl()"></td>
| </tr>
| <tr>
|         <td>Max. Teilnehmerzahl: </td>
|
|         <td><input name="vteilz" id="vteilz" type="text" size="1"
| maxlength="3"
| ></td>
| </tr>
| -----------------------------
| function DisableTeilnehmerzahl() {
|         if (document.new_veranstaltung.vanm.checked == true) {
|                 document.new_veranstaltung.vteilz.disabled=true;
|                 document.new_veranstaltung.vteilz.value="0";
|         } else {
|                 document.new_veranstaltung.vteilz.disabled=false;
|                 document.new_veranstaltung.vteilz.value="";
|         }
| }
| -----------------------------
| When the "vanm" checkbox is being checked the text input "vteilz" should be
| deactivated and become the value 0. By sending the form parameters to a php
| script I'm getting for the variable $_POST['vteilz'] NULL instead of 0.
| Can someone help me?
|
| Thanks in advance

Disabled controls are not transmitted via the POST form command.
What you'll need to do is (in php):
vteilz = ( isset($_POST['vteilz']) ? $_POST['vteilz'] : 0;
 
C

Cah Sableng

-----------------------------
function DisableTeilnehmerzahl() {
if (document.new_veranstaltung.vanm.checked == true) {
document.new_veranstaltung.vteilz.disabled=true;
document.new_veranstaltung.vteilz.value="0";
} else {
document.new_veranstaltung.vteilz.disabled=false;
document.new_veranstaltung.vteilz.value="";
}}

To prevent changes, why don't you just change it to readonly?
The value is still submitted then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top