Foros del Web » Programando para Internet » Javascript »

Textarea en vez de select

Estas en el tema de Textarea en vez de select en el foro de Javascript en Foros del Web. Buenas, Estoy usando la aplicacion JSRS select para hacer busquedas multiples. Me funciona correctamente como lo quiero pero quiero que la ultima busqueda de los ...
  #1 (permalink)  
Antiguo 22/09/2009, 11:05
 
Fecha de Ingreso: agosto-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Textarea en vez de select

Buenas,
Estoy usando la aplicacion JSRS select para hacer busquedas multiples. Me funciona correctamente como lo quiero pero quiero que la ultima busqueda de los tres selects que me aparecen lo haga en un textarea en vez de un select. Me sale un primer select de paises, otro de comunidades y el tercer select en vez de en desplegable lo quiero en textarea. He estado cambiando el codigo de tercer select por un <textarea> pero cuando lo hago peta el sistema. Os pego los codigos a ver si me podeis echar una mano.

Un saludo y gracias

Result.php:

$make = isset($_POST['lstMake']) ? $_POST['lstMake'] : -99;
$model = isset($_POST['lstModel']) ? $_POST['lstModel'] : -99;
$options = isset($_POST['lstOptions']) ? $_POST['lstOptions'] : -99;
?>
<body onload="preselect('<?php echo $make;?>', '<?php echo $model;?>', '<?php echo $options;?>', 1);">
<form name="QForm" action="./select.php" method="post">
<legend></legend>
<p>&nbsp;</p>
<table width="150" border="0">
<tr>
<td><select name="lstMake" id="lstMake">
<option>--------- Not Yet Loaded ---------</option>
</select></td>
<td><select name="lstModel" id="lstModel">
<option>--------- Not Yet Loaded ---------</option>
</select></td>
</tr>
</table>
<p>&nbsp;</p>
<p>
<select name="lstOptions" id="lstOptions">
<option>--------- Not Yet Loaded ---------</option>
</select>
</p>
  #2 (permalink)  
Antiguo 22/09/2009, 11:05
 
Fecha de Ingreso: agosto-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Respuesta: Textarea en vez de select

selectphp.js:
/************************************************** ************

result.php by Milfson ([email protected]) 17.04.2004

Milfson added preselect(parameters...) to pre-populate dropdowns with default values.

Thanks for the code! - Brent.

************************************************** *************/

// constants
var noValue = '-99';
// default values
var IDMake = noValue;
var IDModel = noValue;
var IDOptions = noValue;
//selects disabled true/false
var boolEnabled = true;

// globals
var curOption = new Array();
var isLoaded = new Array();

function initLists(){
// initialize lists
emptyList( 'lstMake' );
emptyList( 'lstModel');
emptyList( 'lstOptions' );
jsrsExecute( 'select_rs.php', cbFillMake, 'makeList');
}

function preselect(idMake,idModel,idOptions,selectable){
boolEnabled = selectable;
IDMake = idMake;
IDModel = idModel;
IDOptions = idOptions;
initLists();
}

function lstMake_onChange(){
var val = this.options[this.selectedIndex].value;
IDMake = val;
IDModel = noValue;
IDOptions = noValue;
if(val == noValue){
selectOption( this.name, curOption[this.name] )
} else {
curOption[this.name] = val;
// init dependent lists
emptyList( 'lstModel' );
emptyList( 'lstOptions');
window.status = 'Loading Model Selections...';
jsrsExecute( 'select_rs.php', cbFillModel, 'modelList', val);
}
}

function lstModel_onChange(){

var val = this.options[this.selectedIndex].value;
if(val == noValue){
selectOption( this.name, curOption[this.name] )
} else {
curOption[this.name] = val;
emptyList( 'lstOptions');
window.status = 'Loading Options Selections...';
jsrsExecute( 'select_rs.php', cbFillOptions, 'optionsList', val);
}
}

function lstOptions_onChange(){
var val = this.options[this.selectedIndex].value;
IDOptions = val;
if(val == noValue){
selectOption( this.name, curOption[this.name] )
} else {
var msg = "You have selected: \n\n";
msg += this.form.lstMake.options[this.form.lstMake.selectedIndex].text + "\n";
msg += this.form.lstModel.options[this.form.lstModel.selectedIndex].text + "\n";
msg += this.options[this.selectedIndex].text + "\n";
//alert (msg);

if(boolEnabled){
document.getElementById('cmdSubmit').disabled="";
document.getElementById('show').style.backgroundCo lor="#FFCC99";
}

}
}

function cbFillMake ( strMakes ){
window.status = '';
fillList( 'lstMake', strMakes );
if(IDMake != noValue){
jsrsExecute( 'select_rs.php', cbFillModel, 'modelList', ''+IDMake+'');
}
}

function cbFillModel ( strModels ){
// callback for dependent listbox
window.status = '';
fillList( 'lstModel', strModels );
if(IDModel != noValue){
jsrsExecute( 'select_rs.php', cbFillOptions, 'optionsList', ''+IDModel+'');
}
}

function cbFillOptions( strOptions ){
// callback for dependent listbox
window.status = '';
fillList( 'lstOptions', strOptions );
}

function fillList( listName, strOptions ){
// fill any list with options
emptyList( listName );

// always insert selection prompt
var lst = document.forms['QForm'][listName];
lst.disabled = true;
lst.options[0] = new Option('=> Please Select <=', noValue);

// options in form "value~displaytext|value~displaytext|..."
var aOptionPairs = strOptions.split('|');
for( var i = 0; i < aOptionPairs.length; i++ ){
if (aOptionPairs[i].indexOf('~') != -1) {
var aOptions = aOptionPairs[i].split('~');
lst.options[i + 1] = new Option(aOptions[1], aOptions[0]);
}
}
switch(listName){
case 'lstMake':
ID = IDMake;
break;
case 'lstModel':
ID = IDModel;
break;
case 'lstOptions':
ID = IDOptions;
break;
}
// init to no value
selectOption( listName, ID );
isLoaded[listName] = true;
lst.disabled = !boolEnabled;
lst.onchange = eval( listName + "_onChange" );
// eval( "document.forms['QForm']['" + listName + "'].onchange=" + listName + "_onChange;" );
}

function emptyList( listName ){
var lst = document.forms['QForm'][listName];
lst.options.length = 0;
lst.onchange = null;
lst.disabled = !boolEnabled;
isLoaded[listName] = false;
curOption[listName] = noValue;
}

function selectOption( listName, optionVal ){
// set list selection to option based on value
var lst = document.forms['QForm'][listName];
for( var i = 0; i< lst.options.length; i++ ){
if( lst.options[i].value == optionVal ){
lst.selectedIndex = i;
curOption[listName] = optionVal;
return;
}
}
}
  #3 (permalink)  
Antiguo 22/09/2009, 11:09
 
Fecha de Ingreso: agosto-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Respuesta: Textarea en vez de select

// callback pool needs global scope
var jsrsContextPoolSize = 0;
var jsrsContextMaxPool = 10;
var jsrsContextPool = new Array();
var jsrsBrowser = jsrsBrowserSniff();
var jsrsPOST = true;
var containerName;

// constructor for context object
function jsrsContextObj( contextID ){

// properties
this.id = contextID;
this.busy = true;
this.callback = null;
this.container = contextCreateContainer( contextID );

// methods
this.GET = contextGET;
this.POST = contextPOST;
this.getPayload = contextGetPayload;
this.setVisibility = contextSetVisibility;
}

// method functions are not privately scoped
// because Netscape's debugger chokes on private functions
function contextCreateContainer( containerName ){
// creates hidden container to receive server data
var container;
switch( jsrsBrowser ) {
case 'NS':
container = new Layer(100);
container.name = containerName;
container.visibility = 'hidden';
container.clip.width = 100;
container.clip.height = 100;
break;

case 'IE':
document.body.insertAdjacentHTML( "afterBegin", '<span id="SPAN' + containerName + '"></span>' );
var span = document.all( "SPAN" + containerName );
var html = '<iframe name="' + containerName + '" src=""></iframe>';
span.innerHTML = html;
span.style.display = 'none';
container = window.frames[ containerName ];
break;

case 'MOZ':
var span = document.createElement('SPAN');
span.id = "SPAN" + containerName;
document.body.appendChild( span );
var iframe = document.createElement('IFRAME');
iframe.name = containerName;
iframe.id = containerName;
span.appendChild( iframe );
container = iframe;
break;

case 'OPR':
var span = document.createElement('SPAN');
span.id = "SPAN" + containerName;
document.body.appendChild( span );
var iframe = document.createElement('IFRAME');
iframe.name = containerName;
iframe.id = containerName;
span.appendChild( iframe );
container = iframe;
break;

case 'KONQ':
var span = document.createElement('SPAN');
span.id = "SPAN" + containerName;
document.body.appendChild( span );
var iframe = document.createElement('IFRAME');
iframe.name = containerName;
iframe.id = containerName;
span.appendChild( iframe );
container = iframe;

// Needs to be hidden for Konqueror, otherwise it'll appear on the page
span.style.display = none;
iframe.style.display = none;
iframe.style.visibility = hidden;
iframe.height = 0;
iframe.width = 0;

break;
}
return container;
}

function contextPOST( rsPage, func, parms ){

var d = new Date();
var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
var doc = (jsrsBrowser == "IE" ) ? this.container.document : this.container.contentDocument;
doc.open();
doc.write('<html><body>');
doc.write('<form name="jsrsForm" method="post" target="" ');
doc.write(' action="' + rsPage + '?U=' + unique + '">');
doc.write('<input type="hidden" name="C" value="' + this.id + '">');

// func and parms are optional
if (func != null){
doc.write('<input type="hidden" name="F" value="' + func + '">');

if (parms != null){
if (typeof(parms) == "string"){
// single parameter
doc.write( '<input type="hidden" name="P[0]" '
+ 'value="[' + jsrsEscapeQQ(parms) + ']">');
} else {
// assume parms is array of strings
for( var i=0; i < parms.length; i++ ){
doc.write( '<input type="hidden" name="P[' + i + ']" '
+ 'value="[' + jsrsEscapeQQ(parms[i]) + ']">');
}
} // parm type
} // parms
} // func

doc.write('</form></body></html>');
doc.close();
doc.forms['jsrsForm'].submit();
}

function contextGET( rsPage, func, parms ){

// build URL to call
var URL = rsPage;

// always send context
URL += "?C=" + this.id;

// func and parms are optional
if (func != null){
URL += "&F=" + escape(func);

if (parms != null){
if (typeof(parms) == "string"){
// single parameter
URL += "&P[0]=[" + escape(parms+'') + "]";
} else {
// assume parms is array of strings
for( var i=0; i < parms.length; i++ ){
URL += "&P[" + i + "]=[" + escape(parms[i]+'') + "]";
}
} // parm type
} // parms
} // func

// unique string to defeat cache
var d = new Date();
URL += "&U=" + d.getTime();

// make the call
switch( jsrsBrowser ) {
case 'NS':
this.container.src = URL;
break;
case 'IE':
this.container.document.location.replace(URL);
break;
case 'MOZ':
this.container.src = '';
this.container.src = URL;
break;
case 'OPR':
this.container.src = '';
this.container.src = URL;
break;
case 'KONQ':
this.container.src = '';
this.container.src = URL;
break;
}
}

function contextGetPayload(){
switch( jsrsBrowser ) {
case 'NS':
return this.container.document.forms['jsrs_Form'].elements['jsrs_Payload'].value;
case 'IE':
return this.container.document.forms['jsrs_Form']['jsrs_Payload'].value;
case 'MOZ':
return window.frames[this.container.name].document.forms['jsrs_Form']['jsrs_Payload'].value;
case 'OPR':
var textElement = window.frames[this.container.name].document.getElementById("jsrs_Payload");
case 'KONQ':
var textElement = window.frames[this.container.name].document.getElementById("jsrs_Payload");
return textElement.value;
}
}

function contextSetVisibility( vis ){
switch( jsrsBrowser ) {
case 'NS':
this.container.visibility = (vis)? 'show' : 'hidden';
break;
case 'IE':
document.all("SPAN" + this.id ).style.display = (vis)? '' : 'none';
break;
case 'MOZ':
document.getElementById("SPAN" + this.id).style.visibility = (vis)? '' : 'hidden';
case 'OPR':
document.getElementById("SPAN" + this.id).style.visibility = (vis)? '' : 'hidden';
this.container.width = (vis)? 250 : 0;
this.container.height = (vis)? 100 : 0;
break;
}
}

// end of context constructor

function jsrsGetContextID(){
var contextObj;
for (var i = 1; i <= jsrsContextPoolSize; i++){
contextObj = jsrsContextPool[ 'jsrs' + i ];
if ( !contextObj.busy ){
contextObj.busy = true;
return contextObj.id;
}
}
// if we got here, there are no existing free contexts
if ( jsrsContextPoolSize <= jsrsContextMaxPool ){
// create new context
var contextID = "jsrs" + (jsrsContextPoolSize + 1);
jsrsContextPool[ contextID ] = new jsrsContextObj( contextID );
jsrsContextPoolSize++;
return contextID;
} else {
alert( "jsrs Error: context pool full" );
return null;
}
}

function jsrsExecute( rspage, callback, func, parms, visibility ){
// call a server routine from client code
//
// rspage - href to asp file
// callback - function to call on return
// or null if no return needed
// (passes returned string to callback)
// func - sub or function name to call
// parm - string parameter to function
// or array of string parameters if more than one
// visibility - optional boolean to make container visible for debugging

// get context
var contextObj = jsrsContextPool[ jsrsGetContextID() ];
contextObj.callback = callback;

var vis = (visibility == null)? false : visibility;
contextObj.setVisibility( vis );

if ( jsrsPOST && ((jsrsBrowser == 'IE') || (jsrsBrowser == 'MOZ'))){
contextObj.POST( rspage, func, parms );
} else {
contextObj.GET( rspage, func, parms );
}

return contextObj.id;
}

function jsrsLoaded( contextID ){
// get context object and invoke callback
var contextObj = jsrsContextPool[ contextID ];
if( contextObj.callback != null){
contextObj.callback( jsrsUnescape( contextObj.getPayload() ), contextID );
}
// clean up and return context to pool
contextObj.callback = null;
contextObj.busy = false;
}

function jsrsError( contextID, str ){
alert( unescape(str) );
jsrsContextPool[ contextID ].busy = false
}

function jsrsEscapeQQ( thing ){
return thing.replace(/'"'/g, '\\"');
}

function jsrsUnescape( str ){
// payload has slashes escaped with whacks
return str.replace( /\\\//g, "/" );
}

function jsrsBrowserSniff(){
if (document.layers) return "NS";
if (document.all) {
// But is it really IE?
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_konq = (agt.indexOf("konqueror") != -1);
if(is_opera) {
return "OPR";
} else {
if(is_konq) {
return "KONQ";
} else {
// Really is IE
return "IE";
}
}
}
if (document.getElementById) return "MOZ";
return "OTHER";
}
  #4 (permalink)  
Antiguo 22/09/2009, 11:20
 
Fecha de Ingreso: agosto-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Respuesta: Textarea en vez de select

Otra forma de mostrar el formulario:

<html>
<head>
<title>JSRS Select Demo</title>
<script language="javascript" src="jsrsClient.js"></script>
<script language="javascript" src="selectphp.js"></script>
<style>
body{background:#dddddd;text-align:center;}
#sel {width:100%;margin: 0px auto 0px auto;}
#show {background-color:darkgray;width:80%;height:45px;text-align:center;margin-top:15px;padding-top:10px;}
</style>
</head>
<?php
$make = isset($_POST['lstMake']) ? $_POST['lstMake'] : -99;
$model = isset($_POST['lstModel']) ? $_POST['lstModel'] : -99;
$options = isset($_POST['lstOptions']) ? $_POST['lstOptions'] : -99;
?>
<body onLoad="preselect('<?php echo $make;?>', '<?php echo $model;?>', '<?php echo $options;?>', 1);" onhelp="jsrsDebugInfo();return false;">

<form name="QForm" method="post" action="./result.php">
<div id="sel">
<table class="normal" width="575" BORDER="0" CELLSPACING="2" CELLPADDING="2" VALIGN="TOP">
<?php
SelectBox ("Make", "lstMake");
SelectBox ("Model", "lstModel");
SelectBox ("Options", "lstOptions");
?>
</table>

</div>
</form>


</body>
</html>
<?php

function SelectBox( $Label, $selectName ){
?>
<tr ALIGN="LEFT">
<td width="15%"><?php echo $Label ?></td>
<td align="left">
<select name="<?php echo $selectName ?>">
<option></option><option></option><option></option>
<option>--------- Not Yet Loaded ---------</option>
</select>
</td>
</tr>
<?php
}
?>

Lo que me gustaria es que el tercer selectbox fuese un textarea
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:59.