1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Hiding a "Channel", but not a "Category"

Discussion in 'PHP' started by chrisj, Jul 19, 2016.

  1. #1
    In a php video-web-script that I'm using, I modified the (video)Upload Form by hiding the select-a-channel drop-down choices, in the Form, essentially like this:

    <li><input type="hidden" name="channel" value="1"/></li>
    Code (markup):
    (so, that the Channel is pre-determined for the uploader/user).

    But, when the Channel is hidden like that, the next field box(sub-categories) in the Form, shows no choices. Apparently, in this Upload Form a Channel choice is required in order to see the sub-category choices.

    So, I'm trying to figure out a way to hide the channel, but somehow let the Form know that Channel has been chosen, so that the sub-category drop-down choices are available for choosing, and proceeding.

    Here's the code without the hidden Channel:

    <li style="width:240px; text-align:right;"><strong>[var.lang_select_channel]:</strong></li>
    <li style="width:400px; text-align:left;">
    
    <select class="upload-video-form-input" style="width:160px;" size="1" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);">
    &nbsp;[var.fields_all;htmlconv=no]</select>&nbsp;([var.lang_select_one])</li>
    
    <li style="width:240px; text-align:right">&nbsp;</li>
    <li style="width:380px" class="font5_14"><strong>[var.lang_sub_categories]</strong></li>
    
    <li style="width:240px; text-align:right"><strong>[var.lang_sub_cat]:&nbsp;</strong></li>
    <li style="width:400px; text-align:left;" id="sub_change"><select class="upload-video-form-input" style="width:160px;" size="1" name="sub_cat"></select>&nbsp;([var.lang_optional])</li>
    Code (markup):
    Any ideas regarding "hide the channel, but somehow let the Form know that Channel has been chosen, so that the sub-category drop-down choices are available for choosing" will be greatly appreciated.
     
    chrisj, Jul 19, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Well, the upload form script seems as crappy code, but it seems you're using php in the background. Just ignore (remove) the inline javascript and pull the content directly into the form via php. Look at the file the javascript pulls data from to see what content to pull.
     
    PoPSiCLe, Jul 19, 2016 IP
  3. chrisj

    chrisj Well-Known Member

    Messages:
    606
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Thanks for your reply.
    I believe this is the javascript code. Can you help me locate "the file the javascript pulls data from"?

    /* USAGE:
    
    
    
    1) Posting data to form:
    
    <form id="myform" action="javascript:ahahscript.likeSubmit('helloworld.php', 'post', 'myform', 'mytarget');">
    
    
    
                                            ('comments_ajax.php', 'commentajax', '', 'GET', '', this)
    
    2) Getting simple url
    
    
    
    <a href="#" onclick="javascript:ahahscript.ahah('test.htm', 'mytaget', '', 'GET', '', this);">click me</a>
    
    
    
    */
    
    
    
    var ahahscript = {
    
    
    
        //loading : 'loading...',
    
        loading : "<br /><img src=javascripts/loading.gif",
    
    
    
        ahah : function (url, target, delay, method, parameters) {
    
    
    
          if ( ( method == undefined ) || ( method == "GET" ) || ( method == "get" ) ){
    
    
    
                this.creaDIV(target, this.loading);
    
    
    
                if (window.XMLHttpRequest) {
    
                    req = new XMLHttpRequest();
    
                }
    
                else if (window.ActiveXObject) {
    
                    req = new ActiveXObject("Microsoft.XMLHTTP");
    
                }
    
                if (req) {
    
                    req.onreadystatechange = function() {
    
                        ahahscript.ahahDone(url, target, delay, method, parameters);
    
                    };
    
                    req.open(method, url, true);
    
                    req.send("");
    
                }
    
            }
    
            if ( (method == "POST") || (method == "post") ){
    
    
    
                this.creaDIV(target, this.loading);
    
    
    
                if (window.XMLHttpRequest) {
    
                    req = new XMLHttpRequest();
    
                }
    
                else if (window.ActiveXObject) {
    
                    req = new ActiveXObject("Microsoft.XMLHTTP");
    
                }
    
                if (req) {
    
                    req.onreadystatechange = function() {
    
                        ahahscript.ahahDone(url, target, delay, method, parameters);
    
                    };
    
                    req.open(method, url, true);
    
                    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    
                    req.send(parameters);
    
                 }
    
            }
    
        },
    
    
    
        creaDIV : function (target, html){
    
            if (document.body.innerHTML) {
    
                document.getElementById(target).innerHTML = html;
    
               }
    
               else if (document.getElementById){
    
                var element = document.getElementById(target);
    
                var range = document.createRange();
    
                range.selectNodeContents(element);
    
                range.deleteContents();
    
                element.appendChild(range.createContextualFragment(html));
    
           }
    
        },
    
    
    
        execJS : function (node) {
    
    
    
            var st = node.getElementsByTagName('SCRIPT');
    
            var strExec;
    
    
    
            var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
    
            var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
    
            var bMoz = (navigator.appName == 'Netscape');
    
    
    
            for(var i=0;i<st.length; i++) {
    
                if (bSaf) {
    
                  strExec = st[i].innerHTML;
    
                }
    
                else if (bOpera) {
    
                  strExec = st[i].text;
    
                }
    
                else if (bMoz) {
    
                  strExec = st[i].textContent;
    
                }
    
                else {
    
                  strExec = st[i].text;
    
                }
    
                try {
    
                  eval(strExec);
    
                } catch(e) {
    
                  alert(e);
    
                }
    
            }
    
    
    
        },
    
    
    
        ahahDone : function (url, target, delay, method, parameters) {
    
            if (req.readyState == 4) {
    
                element = document.getElementById(target);
    
                if (req.status == 200) {
    
    
    
                    //this.creaDIV(target, req.responseText);
    
                    output = req.responseText;
    
                    document.getElementById(target).innerHTML = output;
    
                    var j = document.createElement("div");
    
                    j.innerHTML = "_" + output + "_";
    
                    this.execJS(j);
    
    
    
                }
    
                else {
    
                    this.creaDIV(target, "ahah error:\n"+req.statusText);
    
                }
    
            }
    
        },
    
    
    
        /*
    
    
    
        @@ parameters :
    
        fileName    = name of your cgi or other
    
        method        = GET or POST, default is GET
    
        formName    = name of your form
    
        dynamicTarget    = name of your dynamic Target DIV or other
    
    
    
        @@ usage :
    
    
    
    
    
        */
    
    
    
        likeSubmit : function ( file, method, formName, target ) {
    
    
    
            var the_form = document.getElementById(formName);
    
            var num = the_form.elements.length;
    
            var url = "";
    
            var radio_buttons = new Array();
    
            var nome_buttons = new Array();
    
            var check_buttons = new Array();
    
            var nome_buttons = new Array();
    
    
    
    
    
            // submit radio values
    
            var j = 0;
    
            var a = 0;
    
            for(var i=0; i<the_form.length; i++){
    
                var temp = the_form.elements[i].type;
    
                if ( (temp == "radio") && ( the_form.elements[i].checked) ) {
    
                    nome_buttons[a] = the_form.elements[i].name;
    
                    radio_buttons[j] = the_form.elements[i].value;
    
                    j++;
    
                    a++;
    
                }
    
            }
    
            for(var k = 0; k < radio_buttons.length; k++) {
    
                url += nome_buttons[k] + "=" + radio_buttons[k] + "&";
    
            }
    
    
    
            // submit checkbox values
    
            var j = 0;
    
            var a = 0;
    
            for(var i=0; i<the_form.length; i++){
    
                var temp = the_form.elements[i].type;
    
                if ( (temp == "checkbox") && ( the_form.elements[i].checked) ) {
    
                    nome_buttons[a] = the_form.elements[i].name;
    
                    check_buttons[j] = the_form.elements[i].value;
    
                    j++;
    
                    a++;
    
                }
    
            }
    
            for(var k = 0; k < check_buttons.length; k++) {
    
                url += nome_buttons[k] + "=" + check_buttons[k] + "&";
    
            }
    
    
    
            // submit all kind of input
    
            for (var i = 0; i < num; i++){
    
    
    
                var chiave = the_form.elements[i].name;
    
                var valore = the_form.elements[i].value;
    
                var tipo = the_form.elements[i].type;
    
    
    
                //var valore_2 = valore.replace(/&#160;/,"OK&nbsp;Space"));
    
                //alert(valore_2);
    
    
    
                if ( (tipo == "submit") || (tipo == "radio") || (tipo == "checkbox") ){}
    
                else {
    
                    url += chiave + "=" + valore + "&";
    
                }
    
            }
    
    
    
            //alert(url);
    
    
    
            var ajax_space_fix = url;
    
            var intIndexOfExtraSpace = ajax_space_fix.indexOf( "&#160;" );
    
    
    
            while (intIndexOfExtraSpace != -1)
    
            {
    
                ajax_space_fix = ajax_space_fix.replace( "&#160;", " " )
    
                intIndexOfExtraSpace = ajax_space_fix.indexOf( "&#160;" );
    
            }
    
    
    
            //alert( ajax_space_fix );
    
    
    
            var parameters = ajax_space_fix; //url;
    
    
    
            url = file + "?" + url;
    
    
    
            if (method == undefined) {
    
                method = "GET";
    
            }
    
            if (method == "GET") {
    
                this.ahah(url, target, '', method, '');
    
            }
    
            else {
    
                this.ahah(file, target, '', method, parameters);
    
            }
    
        }
    
    
    
    };
    Code (JavaScript):
    Any help will be appreciated.
     
    chrisj, Jul 20, 2016 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    The file is uploader.php - just as it says in the "onchange" part of your form (the first code you pasted)
     
    PoPSiCLe, Jul 20, 2016 IP
  5. chrisj

    chrisj Well-Known Member

    Messages:
    606
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    Any additional help with how to(maybe a code example) " Just ignore (remove) the inline javascript and pull the content directly into the form via php", will be appreciated.

    Someone who looked at the files had this to say (it's a bit over my head):
    "the javascript executes uploader.php?sub_cat=1.
    The uploader.php returns the list of subcategories in html
    and the ahah script moves it to the correct section on the inner_uploader.htm
    Move the javascript off the onchange to just do it anyway and pass the channel value of 1 directly into uploader.
    I just think maybe the javascript isn't being executed for whatever reason"
     
    chrisj, Aug 5, 2016 IP