Foros del Web » Programando para Internet » Javascript »

insertar input type en form II

Estas en el tema de insertar input type en form II en el foro de Javascript en Foros del Web. la posteo de nuevo para que me entiendan el script modificado es este, le quite los "location.href="pagina800x600.htm"" pues no los necesito <script language="JavaScript"> if (screen.width ...
  #1 (permalink)  
Antiguo 19/11/2002, 22:20
Avatar de ElAprendiz  
Fecha de Ingreso: enero-2002
Ubicación: Maipu, Chile
Mensajes: 3.706
Antigüedad: 22 años, 3 meses
Puntos: 2
insertar input type en form II

la posteo de nuevo para que me entiendan

el script modificado es este, le quite los "location.href="pagina800x600.htm"" pues no los necesito


<script language="JavaScript">
if (screen.width + "x" +screen.height == "640x480") {
resolucion.value = "640x480"
}

if (screen.width + "x" +screen.height == "800x600") {
resolucion.value = "800x600"
}

if (screen.width + "x" +screen.height == "1024x768") {
resolucion.value = "1024x768"
}
</script>
mas bajo tengo el formulario:

<form action="index.asp">
<input name="usuario" type="text" id="textfield" size="12" maxlength="30">
<input name="password" type="password" size="12" maxlength="30">
<input type="submit" name="Submit" value="Enviar" id="Submit">
<input type="hidden" name="resolucion">
</form>

solo quiero ponerle al value de <input type="hydden" name="resolucion"> el valor de la variable de mas arriba
lo puse como me dijo puntito y nada, luego pense quiza le falta algo. probe todas estas y nada.

<input type="hidden" name="resolucion" value="resolucion">
<input type="hidden" name="resolucion" value="javascript:resolucion">
<input type="hidden" name="resolucion" value="resolucion.value">
<input type="hidden" name="resolucion" value=resolucion.value>

diganme que estoy haciendo mal
__________________
Manual de ASP Avanzado ;-)
  #2 (permalink)  
Antiguo 20/11/2002, 01:32
Avatar de Tx
Tx
 
Fecha de Ingreso: enero-2002
Ubicación: Cba - Arg
Mensajes: 188
Antigüedad: 22 años, 3 meses
Puntos: 1
Hola, probá así, te modifique el script un poquito:


<script language="JavaScript">
<!--
function resolucion(){
var ancho = screen.width;
var alto = screen.height;


if ((ancho == "640") && (alto == "480")) {
datos.resolucion.value = "640x480";
}else if ((ancho == "800") && (alto == "600")) {
datos.resolucion.value = "800x600";
}else if ((ancho == "1024") && (alto == "768")) {
datos.resolucion.value = "1024x768";
}
}
window.onload = resolucion;
//-->
</script>


El formulario:


<form name="datos" action="" method="get">
<input name="usuario" type="text" id="textfield" size="12" maxlength="30">
<input name="password" type="password" size="12" maxlength="30">
<input type="hidden" name="resolucion">
<input type="submit" name="Submit" value="Enviar" id="Submit">
</form>


Pero si lo que querés es saber la resolucion es más fácil así, con el mismo formulario:


<script language="JavaScript">
<!--
function resolucion(){
var ancho = screen.width;
var alto = screen.height;
resolucionUSR = ancho + "x" + alto;
datos.resolucion.value = resolucionUSR;
}
window.onload = resolucion;
//-->
</script>


Suerte....
  #3 (permalink)  
Antiguo 20/11/2002, 01:42
Avatar de ElAprendiz  
Fecha de Ingreso: enero-2002
Ubicación: Maipu, Chile
Mensajes: 3.706
Antigüedad: 22 años, 3 meses
Puntos: 2
ok lo vere y te cuento

Pd: creo que me estoy quedando piti
__________________
Manual de ASP Avanzado ;-)
  #4 (permalink)  
Antiguo 21/11/2002, 19:44
Avatar de ElAprendiz  
Fecha de Ingreso: enero-2002
Ubicación: Maipu, Chile
Mensajes: 3.706
Antigüedad: 22 años, 3 meses
Puntos: 2
pues no sale!!!


no me envia la variable!!!
:(
__________________
Manual de ASP Avanzado ;-)
  #5 (permalink)  
Antiguo 24/11/2002, 12:37
Avatar de ElAprendiz  
Fecha de Ingreso: enero-2002
Ubicación: Maipu, Chile
Mensajes: 3.706
Antigüedad: 22 años, 3 meses
Puntos: 2
__________________
Manual de ASP Avanzado ;-)
  #6 (permalink)  
Antiguo 24/11/2002, 13:04
Avatar de caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años
Puntos: 1284
Hola ElAprendiz:

Creo que la asignación la deberías hacer poniendo un onsubmit, o en un body onload.
<body onload=resolucion()>, y usar la función resolución que pone Tx

Saludos
  #7 (permalink)  
Antiguo 24/11/2002, 13:15
Avatar de atlante  
Fecha de Ingreso: julio-2002
Ubicación: Lima
Mensajes: 140
Antigüedad: 21 años, 9 meses
Puntos: 0
Exclamación detalles !!!

Bueno eso es muy sencillo.

primer error:

la instruccion java script se ejecuta antes del codigo html por lo cual si tu deseas enviar un valor a una variable que aun no ha sido creada ,pues no puedes

segundo error :
la instruccion :window.onload=resolucion;
no es valida ya que ese objeto no existe en la intaxis java script

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language="JavaScript">
function resolucion(){
if (screen.width + "x" +screen.height == "640x480") {
document.abc.resolucion.value = "640x480" ;
}
if (screen.width + "x" +screen.height == "800x600") {
document.abc.resolucion.value = "800x600";
}
if (screen.width + "x" +screen.height == "1024x768") {
document.abc.resolucion.value = "1024x768" ;
}
}
</script>
</HEAD>
<BODY onload="resolucion()">
<form name="abc">
<input name="usuario" type="text" size="12" maxlength="30">
<input name="password" type="password" size="12" maxlength="30">
<input type="submit" name="Submit" value="Enviar">
<input type="hidden" name="resolucion">
</form>

</BODY>
</HTML>

__________________
If you look, If you really read between the lines, You will see...
  #8 (permalink)  
Antiguo 25/11/2002, 02:40
Usuario no validado
 
Fecha de Ingreso: julio-2001
Mensajes: 766
Antigüedad: 22 años, 9 meses
Puntos: 0
con esto debe de ser suficiente


<script language="JavaScript">
function res()
{
document.pantalla.resolucion.value = screen.width + "x" +screen.height
}
window.onload=res
</script>
mas bajo tengo el formulario:

<form name="pantalla" action="index.asp">
<input name="usuario" type="text" id="textfield" size="12" maxlength="30">
<input name="password" type="password" size="12" maxlength="30">
<input type="submit" name="Submit" value="Enviar" id="Submit">
<input type="hidden" name="resolucion">
</form>



una cosa como que el window.onload no existe
mira que el navegador te lo diga

<script language="Javascript">
for(var abc in window)
document.write(abc+"<br>")
</script>
  #9 (permalink)  
Antiguo 25/11/2002, 04:58
Avatar de Helbira  
Fecha de Ingreso: octubre-2001
Ubicación: Sevilla, España
Mensajes: 1.228
Antigüedad: 22 años, 6 meses
Puntos: 5
<html>
<head>
<title>Untitled Document</title>
<script language="JavaScript">
<!--
function calculaResolucion() {
if (screen.width + "x" +screen.height == "640x480") {
document.miFormulario.resolucion.value = "640x480";
}
if (screen.width + "x" +screen.height == "800x600") {
document.miFormulario.resolucion.value = "800x600";
}
if (screen.width + "x" +screen.height == "1024x768") {
document.miFormulario.resolucion.value = "1024x768";
}
else
document.miFormulario.resolucion.value = "1024x768";
alert('RESOLUCION: '+ document.miFormulario.resolucion.value);
return true;
}
//-->
</script>
</head>

<body>
<form name="miFormulario" action="index.asp" onSubmit="return calculaResolucion();">
<input name="usuario" type="text" id="textfield" size="12" maxlength="30">
<input name="password" type="password" size="12" maxlength="30">
<input type="hidden" name="resolucion" value="">

<input type="submit" name="Submit" value="Enviar" id="Submit">
</form>
</body>
</html>


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 06:18.