How to get a text input value into a php script

Discussion in 'Javascript' started by Todor Vachkov, Apr 13, 2007.

  1. 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
    Todor Vachkov, Apr 13, 2007
    #1
    1. Advertising

  2. Todor Vachkov

    Jeff North Guest

    On Fri, 13 Apr 2007 13:25:38 +0200, in comp.lang.javascript Todor
    Vachkov <-berlin.de>
    <> wrote:

    >| 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;
    ---------------------------------------------------------------
    : Remove your pants to reply
    ---------------------------------------------------------------
    Jeff North, Apr 13, 2007
    #2
    1. Advertising

  3. Todor Vachkov

    Cah Sableng Guest

    On Apr 13, 6:25 pm, Todor Vachkov <-berlin.de>
    wrote:

    > -----------------------------
    > 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.
    Cah Sableng, Apr 13, 2007
    #3
  4. Thanks a lot folks!
    Now I figured out where was the problem;)
    Todor Vachkov, Apr 13, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rajive Narain
    Replies:
    0
    Views:
    1,459
    Rajive Narain
    Sep 18, 2009
  2. Susan Cranford
    Replies:
    2
    Views:
    385
  3. Dwizz
    Replies:
    10
    Views:
    379
  4. Replies:
    1
    Views:
    124
  5. Replies:
    2
    Views:
    138
Loading...

Share This Page