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

<li><input type="hidden" name="channel" value="1"/></li>

(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 name the channel, and 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> 

Any ideas regarding naming the channel, and 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.

    Thanks. But Webdeveloper seems to be having issues

      First off, I'm shooting from the hip here. I'm not really sure what this system is or what you're wanting to do.

      It appears to me that some type of script (which I assume is performing AJAX) is contacting "uploader.php" with the details of the channel, but only if it's changed (via the "onchange" event, which also means, I assume, that a default "no channel" is the original state of the control).

      If you want to enforce a certain channel only, you might try one of these ideas:

      a] muck around in "uploader.php" and figure out what it does. One guess is that it returns a channel number, a better one is that it returns a list of sub-categories, and a freaky one is that it manipulates $COOKIE or $SESSION for this particular user and then the rest of the form reads from there. You'd then have to hack it to do your will instead of the original programmer. Probably not a great solution ... you might have users changing the control and then wondering why they get the same sub-channels no matter what they choose first ...

      b] Hack the JS and HTML to say what you want. You might have to assign static values to the JS variables, etc. Once again, not sure if it's a good solution, but it might work. You could, maybe, assign the vars that produce subchannels statically and then hide the selector.

      c] You said:

      chrisj wrote:

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

      So perhaps what you really want to do is intercept the JavaScript, attaching an event to the DOM at load time, that calls ahahscript.ahah to contact uploader.php with $your_channel_choice in place of "document.form_upload.channel.value". But I can't tell you exactly how to do that without a lot more information, and I'm not really even sure it'll work. It SHOULD, but only if I really understand the problem.

      HTH,

        Thanks so much for your reply. Much appreciated. Yes, it's a php web script that uses AJAX. I'm wondering if I post the ahah code, if someone can tell me where I might modify it to put a fixed channel value:

        // ==========================================================================
        
        // @function		Complete AHAH function
        
        // @author		Daniele Florio
        
        // @site		www.gizax.it
        
        // @version		1.1.3 experimental
        
        
        
        // @thanksTo		Andrea Paiola,Walter Wlodarski,Scott Chapman
        
        
        
        // @updated 1.1.3 ( execJS function ) @thanks to Giovanni Zona
        
        
        
        // (c) 2006 Daniele Florio <daniele@gizax.it>
        
        
        
        // ==========================================================================
        
        
        
        /* 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);
        
        	}
        
        }
        
        
        
        }; 

          First thing I'd try is this, assuming that channel "1" is indeed your chosen value:

          // ORIGINAL
          //onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);">
          
          //NEW
          onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat=1', 'sub_change', '', 'GET', '', this);">

            Thanks a lot for your reply. I really appreciate your suggestion.

            However, I tried this without success:

            <input type="hidden" name="channel" value="1"/></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=1', 'sub_change', '', 'GET', '', this);">
            &nbsp;[var.fields_all;htmlconv=no]</select>&nbsp;([var.lang_select_one])
            </li> 

            any additional guidance with this will be welcomed. Much thanks again.

              As this isn't a JavaScript forum (although it is the ClientSide sub-forum), it's going to be hard to find someone with the right combination of dedication to the task (for free) and experience in this sort of debugging (via a forum, a rather difficult way to debug JavaScript). I assume you're familiar with the Debugger Console in whatever browser you're using? That's the place to start. Look and see what's being sent to "uploader.php" and see what the response is. Look at the JavaScript function(s) that produce the subcategories and what input they expect. Look at these function and see what they DO to produce the results you don't want, because this is probably the key to getting the results you DO want.

              Report back here, but I can't say if we'll make any progress.

              I suppose I should also add: consider hiring professional "on-site" (or at least remote with privileges) help if necessary.

                Thanks for your reply.

                I'll try that. However, if it ends up that I have to simply hide the channel and then hard-code the sub-categories into the Form, can you help me get started with that, with a code example, on how to change this code to a hard-coded drop down list?

                <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>

                Any guidance will be appreciated

                  Write a Reply...