Jump to content
php.lv forumi
  • 0

Aptauja


Question

Posted

Gribētos uztaisīt aptauju lapā bez refresha un submit pogas.

Darbotos šādi: <input type="radio" name="a" value="1" onclick="funkcija()"> teksts

 

Kāda apmēram varētu būt funkcija, kas nepārlādējot lapu nosūtītu datus uz citu failu ( kur tie ievietotos datubāzē ), un tad pārlādētos tikai tas bloks, kur ir aptauja ( <div> </div> )

6 answers to this question

Recommended Posts

  • 0
Posted

palasīju par jQuery funkcijām un atradu šo load()

 

<script language="javascript" type="text/javascript">
function vote(id)
{
$('#poll_content').fadeOut('slow').load('<?=HOMEURL?>/vote/'+id).fadeIn('slow');
}
</script>

  • 0
Posted (edited)

Cita problēma.

Šis kods uz IE9 strādā, bet uz gChrome nē o.O

 

<script type="text/javascript" language="JavaScript">
function getCats(id)
{
if(id!=0)
{
	$('#kat').load('/getcat/'+id);
}
}
</script>
<select name="topcat">
<?php	
$top = query("SELECT rb_topcat_id FROM rb_cat WHERE tips LIKE '%I%' GROUP BY rb_topcat_id");
while($tarr = fetchArray($top))
{
	$q = query("SELECT * FROM rb_topcat WHERE id=".$tarr[0]);
	while($arr = fetchArray($q))
	{
		echo '<option onclick="getCats('.$arr["id"].')">'.$arr["name"].'</option>';
	}
}
?>
</select>
<div id="kat"></div>

 

mēģināju šādi, bet tas nestrādā nevienā pārlūkā

<select name="topcat" onchange="getCats(this.value)">
<?php	
$top = query("SELECT rb_topcat_id FROM rb_cat WHERE tips LIKE '%I%' GROUP BY rb_topcat_id");
while($tarr = fetchArray($top))
{
	$q = query("SELECT * FROM rb_topcat WHERE id=".$tarr[0]);
	while($arr = fetchArray($q))
	{
		echo '<option value="'.$arr["id"].'">'.$arr["name"].'</option>';
	}
}
?>
</select>

Edited by eT`
  • 0
Posted (edited)

Jauns jautājums:

Man ir login forma, kuru validēju ar AJAX

Gribētos, lai logins notiek bez lapas pārlādes.

success gadījumā laikam vajadzētu ielikt kaut ko, kas to DIVu pārlādētu.

 

pašlaik ir šādi:

 

<script type="text/javascript" language="javascript">
function login()
{
var user = document.getElementById('email').value;
var password = document.getElementById('password').value;

   $.ajax({
  	type: "POST",
  	url: "<?=HOMEURL?>/login",
   data: ({mail : user, pass : password }),
   success: function(data) { 
   //šeit vajadzētu ielikt, lai pārlādējas #login bloks
   } 
	});
}
</script>
<div id="login">
<?php
if(empty($_SESSION["logged"]))
{
?>
   <table width="250px">
   <tr><td width="50px">E-Pasts</td><td width="200px"><input name="mail" type="text" id="email" /></td></tr>
   <tr><td width="50px">Parole</td><td width="200px"><input name="pass" type="password" id="password" /></td></tr>
   <tr><td></td><td><input type="button" value="Ielogoties" onclick="login();" /> <a href="<?=HOMEURL?>/register">Reģistrēties</a></td></tr>
   </table>
<?php
}
else
{

echo 'Sveiks,<br />
<a href="'.HOMEURL.'/profile">Mans profils</a><br />
<a href="'.HOMEURL.'/logout">Iziet</a>';
}
?>
</div>

Edited by eT`

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...