0

Using the UI widget, I have the input posting to the mysql database BUT only the first radio choice is ever pulled. I am currently using the selector: ('input:radio[name="ageLimit"]'), but no luck.

Can anyone point me to some info on how to get the other radio value, please? Here are the links I have been drawing my info from: http://www.plupload.com/punbb/viewtopic.php?pid=11098#p11098 http://www.plupload.com/punbb/viewtopic.php?id=177

here is the js:

 $(function() {
$("#uploader").plupload({
    // General settings
    runtimes : 'flash,html5,browserplus,silverlight,gears,html4',
    url : 'upload.php',
    max_file_size : '1000mb',
    max_file_count: 20, // user can add no more then 20 files at a time
    chunk_size : '1mb',
    rename: true,
    multiple_queues : true,
     multipart_params : {
            aud : $('input[name="ageLimit"]').val()
    },

    // Resize images on clientside if we can
    //resize : {width : 320, height : 240, quality : 90},

    // Rename files by clicking on their titles
    rename: true,

    // Sort files
    sortable: true,

    // Specify what files to browse for
    filters : [
        {title : "Image files", extensions : "jpg,gif,png"},
        {title : "Zip files", extensions : "zip,avi"}
    ],

    // Flash settings
    flash_swf_url : 'plupload/js/plupload.flash.swf',

    // Silverlight settings
    silverlight_xap_url : 'plupload/js/plupload.silverlight.xap'
});

// Client side form validation
$('form').submit(function(e) {
    var uploader = $('#uploader').plupload('getUploader');

    // Files in queue upload them first
    if (uploader.files.length > 0) {
        // When all files are uploaded submit form
        uploader.bind('StateChanged', function() {
            if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                $('form')[0].submit();
            }
        });

         uploader.bind('BeforeUpload', function(up) {
              up.settings.multipart_params.aud = $('input[name="ageLimit"]').val();
        });    
        uploader.start();
    } else
        alert('You must at least upload one file.');

    return false;
});
});

here is the validation php:

 //check for audience
    $aud = (!empty($_REQUEST['aud'])) ? trim($_REQUEST['aud']): "";

here is the html:

<form id="myForm"  method="post" action="plupload/examples/dump.php">
 <div>
   <h3>Please select an audience</h3>
   <p><input class="age" type="radio" name="ageLimit" value="allAge"/> All ages </p>
   <p><input class="age" type="radio" name="ageLimit" value="mature"/> Mature</p>
 </div>

<br/>
<div id="transBox" style="display:none">

<div id="uploader">
    <p>Your browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
</div>
</form>

I just now added this to the to check the value

$('#myForm input').on('click', function() {
alert($('input[name="ageLimit"]:checked', '#myForm').val()); 
});

but when I changed the js selectors to this below, again nothing was added to the DB.

$('input[name="ageLimit"]:checked', '#myForm').val()
artsyL
  • 49
  • 1
  • 13
  • I didn't see a selector with ('input:radio[name="ageLimit"]:checked')". Where are you grabbing the value of the checked radio button in the code? – ams Nov 19 '13 at 01:09
  • Sorry, typo. This ('input:radio[name="ageLimit"]:checked') does not post anything to the database, but this does ('input:radio[name="ageLimit"]'). It's in two places in the js. I find this very weird. – artsyL Nov 19 '13 at 01:24
  • Weird. I made a [stripped down version](http://jsfiddle.net/eGBet/5/) of what you posted and it seems to work using the :checked selector. – ams Nov 19 '13 at 01:42
  • why might the alert work, but not the js function? I'm really only a beginner in js and jquery. Thanks, by the way – artsyL Nov 19 '13 at 01:47
  • 1
    Yeah, it's pretty weird. What if you tried putting that alert statement right after the form submit function. Maybe something erases the radio value before your program has a chance to retrieve it. – ams Nov 19 '13 at 01:51
  • You were right. What might be wiping it out? – artsyL Nov 19 '13 at 01:57
  • I'm not familiar with some of the functions you are using, so I can't give you an answer confidently. – ams Nov 19 '13 at 02:02
  • 1
    maybe you can try passing the parameter as query string and see it changes something. See http://stackoverflow.com/a/13382331/1236044 – jbl Nov 19 '13 at 12:51
  • It seems to be passing something else along now ("undefined"), but it is still not picking up the variable. Thanks! – artsyL Nov 19 '13 at 16:20

0 Answers0