Jump to content

Recommended Posts

After checking all the posts on this forum, I tried more caffeine but it didn't work ;)

 

Although this code is within a php script, I believe the issue is an html one (thus this forum), so please ignore the php:

 

The form contains text, radio and select inputs. They are able to be input by the user, yet when I test for them being posted once the script is accessed after posting, the text and select values succeed but the radio values are nil.

 

Form Code:

 

<form method="post" class="" action="script.php">

 

        <div class="row">
            <label for="pronounce_name_as">How is your name pronounced?</label>
            <label id="label_instrn">Optional: for use with ideographic characters such as used in some Asian cultures</label>
    <input type="text" id="pronounce_name_as" name="pronounce_name_as" value="<?php if (isset($trimmed['pronounce_name_as'])) echo $trimmed['pronounce_name_as']; ?>" />
        </div>

        <div class="row">
            <label id="label_radio">Gender *</label>
                <input id="female" type="radio" name="gender" value='female' /> Female<br />
                <input id="male" type="radio" name="gender" value='male' /> Male<br />
        </div>

        <div class="row">
            <label id="label">Communications</label>
            <label id="label_instrn">Optional: this will help us provide you with appropriate study styles</label>
              <select id="label_select" name="comms" >
                  <option value='not_selected' selected>Select ..</option>
                  <option value='wo_speech'>I am without speech</option>
                  <option value='wo_hearing'>I am without hearing</option>
                  <option value='wo_sight'>I am without sight</option>
                  <option value='None'>None of the above</option>
              </select>
        </div>
 

</form>

 

 

Value test code:

 

echo "posted pronounce_name_as = ".$_POST['pronounce_name_as']."<br />";
echo "posted gender = ".$_POST['gender']."<br />";
echo "posted comms = ".$_POST['comms']."<br />";

var_dump($_POST['gender']);
 

 

Output:

 

posted pronounce_name_as = Jai-ms Smy-ly
posted gender =
posted comms = None

 

string(0) ""

 

Any ideas? Should I return to html bootcamp? ;)

 

Link to comment
https://forums.phpfreaks.com/topic/285337-posted-radio-responses-not-working/
Share on other sites

Your code suggests the field is being posted, just with an empty value. There is nothing wrong with your HTML however so I suspect one of two things

 

1) You have some PHP code you did not show which is causing the value to be cleared out or

2) You have some JS code you did not show which is causing the value to be cleared out.

 

Check your browser's developer tools to see what value is being sent in the request to the server. You can find this out from the Net/Network tab usually.

 

Note for future posts, you need to wrap your code in


tags when posting. It makes it much easier to read that way.

Thanks for your advice, kicken. Point on code wraps taken.

 

I checked web console on firefox and it shows no data sent for radio inputs.  Now this gets exhilarating! Whatever is causing this is refusing to accept radio selected data or is deleting radio selected data values before it gallops down to the server. My php code certainly is not involved at the form. And the javascript has nothing to do with these inputs - it's only used for email and pw graphics. Now I'm stumped. 

 

Any other ideas or hints? Mmm .. time for a 'candy bar to brain' moment, methinks.

Edited by tork

Found out what causes this, and you're correct, it is jQuery:

 

$(function(){       /* This is shorthand for $(document).ready(function(){ which ensures all jQuery items are loaded before executing */

});

 

It's not the coding inside it, but just this one statement. Guess I'm off to the javascript forum now ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.