- Fórum WMO
- → Viewing Profile: Tópicos: jg7
Community Stats
- Group Usuários
- Active Posts 3
- Profile Views 239
- Member Title Novato no fórum
- Age Age Unknown
- Birthday Birthday Unknown
-
Sexo
Male
User Tools
Friends
jg7 hasn't added any friends yet.
Topics I've Started
Php - Ajax - Combox Autocompletar
02/04/2012, 15:33
eu como iniciante to tentando duplicar o seguinte codigo:
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
var ajax = new sack();
var currentClientID=false;
function getClientData()
{
var clientId = document.getElementById('clientID').value.replace(/[^0-9]/g,'');
if(clientId.length==4 && clientId!=currentClientID){
currentClientID = clientId
ajax.requestFile = 'edicao.php?getClientId='+clientId;
ajax.onCompletion = showClientData;
ajax.runAJAX();
}
}
function showClientData()
{
var formObj = document.forms['clientForm'];
eval(ajax.response);
}
function initFormEvents()
{
document.getElementById('clientID').onblur = getClientData;
}
window.onload = initFormEvents;
</script>
<div>
<form name="clientForm" action="" method="post">
<select name="clientID" id="clientID">
<option value"Número da p****">Número da p****</option>
<?php
$result = mysql_query("select * from ajax_client");
while($row = mysql_fetch_array($result) ){
echo "<option value='".$row['clientID']."'>".$row['clientID']."</option>";
}
?>
</select>
<input name="firstname" id="firstname" size="20" maxlength="255">
<input name="lastname" id="lastname" size="20" maxlength="255">
<input name="address" id="address" size="20" maxlength="255">
<input name="zipCode" id="zipCode" size="4" maxlength="5">
<input name="city" id="city" size="20" maxlength="255">
<input name="country" id="country" size="20" maxlength="255">
</form>
</div>
edicao.php seria assim:
if(isset($_GET['getClientId'])){
$res = mysql_query("select * from ajax_client where clientID='".$_GET['getClientId']."'") or die(mysql_error());
if($inf = mysql_fetch_array($res)){
echo "formObj.firstname.value = '".$inf["firstname"]."';\n";
echo "formObj.lastname.value = '".$inf["lastname"]."';\n";
echo "formObj.address.value = '".$inf["address"]."';\n";
echo "formObj.zipCode.value = '".$inf["zipCode"]."';\n";
echo "formObj.city.value = '".$inf["city"]."';\n";
echo "formObj.country.value = '".$inf["country"]."';\n";
}else{
echo "formObj.firstname.value = '';\n";
echo "formObj.lastname.value = '';\n";
echo "formObj.address.value = '';\n";
echo "formObj.zipCode.value = '';\n";
echo "formObj.city.value = '';\n";
echo "formObj.country.value = '';\n";
}
}
O que eu queria fazer era duplicar o codigo, tipo assim queria fazer um novo form puxando dados de outra parte do Banco de Dados, isso tudo na mesma pagina.... Exemplo:
<div>
<form name="clientForm" action="" method="post">
<select name="clientID" id="clientID">
<option value"Número da p****">Número da p****</option>
<?php
$result = mysql_query("select * from ajax_client");
while($row = mysql_fetch_array($result) ){
echo "<option value='".$row['clientID']."'>".$row['clientID']."</option>";
}
?>
</select>
<input name="firstname" id="firstname" size="20" maxlength="255">
<input name="lastname" id="lastname" size="20" maxlength="255">
<input name="address" id="address" size="20" maxlength="255">
<input name="zipCode" id="zipCode" size="4" maxlength="5">
<input name="city" id="city" size="20" maxlength="255">
<input name="country" id="country" size="20" maxlength="255">
</form>
</div>
<div>
<form name="senhaForm" action="" method="post">
<select name="senhaID" id="senhaID">
<option value"Número da p****">Número da p****</option>
<?php
$result = mysql_query("select * from outrabd");
while($row = mysql_fetch_array($result) ){
echo "<option value='".$row['senhaID']."'>".$row['senhaID']."</option>";
}
?>
</select>
<input name="usuario" id="usuario" size="20" maxlength="255">
<input name="senha" id="senha" size="20" maxlength="255">
</form>
</div>
Alguem tem uma alternativa?? a duvida é na montagem ali do Javascript.. num to conseguindo
Puxar Resultados Limitando Data
16/09/2011, 17:08
$data_anterior = gmdate("Y-m-d", time()-(3600*27));
$sql = "SELECT * FROM agenda WHERE data > $data_atual ORDER BY data LIMIT 3";
To tentando com este código e nao obtive sucesso, alguma dica?
Abraço
Validação De Formulário
05/07/2011, 00:31
Tenho o seguinte código:
function vld(){
if (document.ej.emp.value.length<3)
{
alert( "Preencha corretamente o campo Nome." );
document.ej.emp.focus();
return false;
}
if(document.ej.imagem.value=="")
{
alert( "Selecione o arquivo de imagem referente à logo." );
document.ej.imagem.focus();
return false;
}
if((document.ej.imagem.value.lastIndexOf(".jpg")==-1) &&
(document.ej.imagem.value.lastIndexOf(".gif")==-1) &&
(document.ej.imagem.value.lastIndexOf(".jpeg")==-1) &&
(document.ej.imagem.value.lastIndexOf(".png")==-1) &&
(document.ej.imagem.value.lastIndexOf(".JPG")==-1) &&
(document.ej.imagem.value.lastIndexOf(".GIF")==-1) &&
(document.ej.imagem.value.lastIndexOf(".JPEG")==-1) &&
(document.ej.imagem.value.lastIndexOf(".PNG")==-1)){
alert( "O formado da imagem selecionada não é válida!" );
document.ej.imagem.focus();
return false;
}
if (document.ej.tf.value.length<14)
{
alert( "Preencha corretamente o campo Telefone." );
document.ej.tf.focus();
return false;
}
return true;
}
Precisava colocar alem de uma restrição de FORMATO no upload (que ja foi feita),
uma restrição de tamanho para no máximo 500KB, porém não estou conseguindo adicionar dentro desta validação
Alguém tem uma ideia?
Abraço !!
- Fórum WMO
- → Viewing Profile: Tópicos: jg7
- Privacy Policy
- Regras ·