| |
Forum PHP IndonesiaDapatkan pertolongan pertama pada kebingungan PHP dan sekitarnya |
|
|
|
|
|
| |
|
|
All times are GMT + 7 Hours
|
|
javascript gabung php
 |
Tue Nov 10, 2009 00:13 |
 |
Author |
Message |
vb_loph PHP Programmer

Joined: 23 May 2009 Posts: 93 Location: Bandung
|
| Post subject: javascript gabung php |
|
|
gimn ya kl gabung javascript dgn php? saya ada kasus dimana saya hrs munculin window confirm sebelum save data ke database?
thx be4... |
|
| |
|
|
 |
Tue Nov 10, 2009 12:10 |
 |
Author |
Message |
junifar PHP Master

Joined: 27 Mar 2008 Posts: 279
|
| Post subject: |
|
|
mungkin maksudnya AJAX kah??? _________________ Salam
Junifar Hidayat |
|
| |
|
|
 |
Tue Nov 10, 2009 16:43 |
 |
Author |
Message |
vb_loph PHP Programmer

Joined: 23 May 2009 Posts: 93 Location: Bandung
|
| Post subject: |
|
|
| junifar wrote: | | mungkin maksudnya AJAX kah??? |
pake ajax bs ya? gimn y caranya? |
|
| |
|
|
 |
Wed Nov 11, 2009 10:03 |
 |
Author |
Message |
junifar PHP Master

Joined: 27 Mar 2008 Posts: 279
|
| Post subject: |
|
|
Ada 2 tipe bos.
- cara klasik pake javascript.
skenarionya pas di submit ditangkap menggunakan javascript lalu ditampilkan menggunakan alert konfirmation javascript
- cara yang lazim saat ini
skenarionya pas klik submit muncul window div untuk confirmation. apabila di klik oke baru di submit. cara ini menggunakan ajax. konsepnya seperti link ini http://pixeline.be/experiments/ThickboxToJqModal/ cukup rumit bagi yang belum memahaminya. Coba anda gunakan jquery, tepatnya jqmodal.
Semoga membantu _________________ Salam
Junifar Hidayat |
|
| |
|
|
 |
Fri Nov 13, 2009 08:32 |
 |
Author |
Message |
hlie Super Master PHP


Joined: 10 Apr 2008 Posts: 2673 Location: Singapore
|
| Post subject: |
|
|
coba bikin 1 function js
function validation()
{
if(document.test.nama.value == '')
{
alert('asdsadsa');
return false;
}else{
return true;
}
}
<form name="test" action="" method="post" onsubmit="return validate();">
<input type=text name=nama >
....
....
nb : itu baru validasi awal buat front end, kl bs di validasi lg pas di php, jadi double secure..
_________________ Past is Experience,Present is Experiments,Future is Expectations,Use your Experience in your Experiments to achieve your Expectations...!!!
www.slackware.com |
|
| |
|
|
 |
Fri Nov 13, 2009 12:10 |
 |
Author |
Message |
fasisi PHPnewbie

Joined: 28 Mar 2009 Posts: 17
|
| Post subject: |
|
|
cara menggabungkannya.. setahu saya sih tinggal di sisipkan aja code-code javascript... selayaknya menyisipkan teks lewat php misalnya echo "<form action=....". _________________ fasisi
www.pasar-programmer.com - wadah ketemu antara programmer dan calon user |
|
| |
|
|
 |
Fri Nov 13, 2009 12:36 |
 |
Author |
Message |
vb_loph PHP Programmer

Joined: 23 May 2009 Posts: 93 Location: Bandung
|
| Post subject: |
|
|
| hlie wrote: | coba bikin 1 function js
function validation()
{
if(document.test.nama.value == '')
{
alert('asdsadsa');
return false;
}else{
return true;
}
}
<form name="test" action="" method="post" onsubmit="return validate();">
<input type=text name=nama >
....
....
nb : itu baru validasi awal buat front end, kl bs di validasi lg pas di php, jadi double secure..
|
validasi lg pas di php maksudnya gimn ya?
yg saya buat sih kyk gini :
| Code: | <?php echo "<script>";
echo "konfirm=window.confirm('Anda Yakin Menyimpan Absen dengan Guru yang Berbeda?');";
echo "if(konfirm==true)";
echo "{";
echo "location.href ='DaftarHadir1.php?kelas=$kelas';";
echo "}";
echo "</script>"; ?> |
tapi yg saya bingung.. kalau saya menggunakan coding ini, saya ga bisa kirim data yg bentuknya array? |
|
| |
|
|
 |
Sat Nov 14, 2009 09:44 |
 |
Author |
Message |
fasisi PHPnewbie

Joined: 28 Mar 2009 Posts: 17
|
| Post subject: |
|
|
@vb_loph
saya juga tidak begitu paham dengan javascript... tapi punya dugaan kamu bisa kirim data form lewat perintah javascript.
waktu bikin form kan ada tag <form> dan ada namanya kan? nah, di javascript kayaknya form itu dianggap sebagai objek.
nah, mungkin objek itu bisa submit pakai fungsi di javascript. mungkin perlu cari informasi lebih banyak tentang javascript.
maaf tidak bisa membantu banyak. _________________ fasisi
www.pasar-programmer.com - wadah ketemu antara programmer dan calon user |
|
| |
|
|
 |
Sat Nov 21, 2009 11:42 |
 |
Author |
Message |
vb_loph PHP Programmer

Joined: 23 May 2009 Posts: 93 Location: Bandung
|
| Post subject: |
|
|
| fasisi wrote: | @vb_loph
saya juga tidak begitu paham dengan javascript... tapi punya dugaan kamu bisa kirim data form lewat perintah javascript.
waktu bikin form kan ada tag <form> dan ada namanya kan? nah, di javascript kayaknya form itu dianggap sebagai objek.
nah, mungkin objek itu bisa submit pakai fungsi di javascript. mungkin perlu cari informasi lebih banyak tentang javascript.
maaf tidak bisa membantu banyak. |
iya.. thx infonya.. tapi yang saya bingung, apakah javacript bisa mengirim array? |
|
| |
|
|
 |
Tue Nov 24, 2009 10:50 |
 |
Author |
Message |
vb_loph PHP Programmer

Joined: 23 May 2009 Posts: 93 Location: Bandung
|
| Post subject: |
|
|
| ada yang tau, apakah javacript bisa mengirim array? |
|
| |
|
|
 |
Tue Nov 24, 2009 12:19 |
 |
Author |
Message |
gecko PHP Master


Joined: 17 Nov 2007 Posts: 361 Location: Trenggalek, Jatim, Indonesia
|
|
| |
|
|
 |
Tue Nov 24, 2009 18:07 |
 |
Author |
Message |
vb_loph PHP Programmer

Joined: 23 May 2009 Posts: 93 Location: Bandung
|
| Post subject: |
|
|
gimn ya caranya? blh minta cthnya? |
|
| |
|
|
 |
Tue Nov 24, 2009 22:39 |
 |
Author |
Message |
ayam_jago PHP Programmer


Joined: 26 Oct 2009 Posts: 92 Location: Lampung
|
| Post subject: Klik aja |
|
|
| vb_loph wrote: |
gimn ya caranya? blh minta cthnya? |
ya itu di click aja www.gecko.web.id  _________________ MyBLOG |
|
| |
|
|
 |
Wed Nov 25, 2009 01:35 |
 |
Author |
Message |
kebeng PHP Programmer


Joined: 09 Aug 2009 Posts: 75 Location: jakarta
|
| Post subject: |
|
|
Oke bos bos..
saya jg ga bisa javascript..
ini script php nya...
| Code: | <?php <script language="JavaScript" src="script/script.js"></script>
<form name="fm12" action="13.php" method="post" onSubmit="return cek12();">
<table align="center">
<tr><th>No</th><th>NIM</th><th>Tahun</th><th>Semester</th></tr>
<?
for ($i=0; $i<$jumlah; $i++)
{
$n=$i+1; ?>
<tr><td align="center"><?=$n?></td>
<td align="center"><select name="nim[]">
<option value="">Pilih</option>
<? include"konek.php";
$c=mysql_query("select * from siswa where status like '%aktif%' order by nim DESC");
while($e=mysql_fetch_array($c))
{
echo"<option value=\"$e[nim]\">$e[nim]</option>";
} ?> </select></td>
<td align="center"><? $t=date("Y");
{ echo"<input type=\"text\" size=\"4\" name=\"tahun[]\" value=\"$t\">"; }
?></td>
<td align="center"><select name="semester[]">
<option value="">Pilih</option>
<option value=1>Ganjil</option>
<option value=2>Genap</option>
</select></td></tr>
<? }
echo "<tr><td colspan=6 align=center><input type=submit value=Simpan name=simpan></td></tr>";
?>
</table></form> ?> |
Dan ini javascript nya bos....
| Code: | <?php function cek12()
{
with(document.fm12)
{
if(nim[].value=="")
{
alert("Maaf no induk belum diisi !")
nim[].focus();
return false;
}
if(tahun[].value=="")
{
alert("Maaf tahun belum diisi !")
tahun[].focus();
return false;
}
if(semester[].value=="")
{
alert("Maaf semester belum diisi !")
semester[].focus();
return false;
}
}
} ?> |
saya uda pake while n for untuk js nya..
| Code: | <?php $i=1;
while ($i<n)
$i++;
//atau
var i,n;
for(i=0; i<n; i++); ?> |
tapi variabel 'n' dari for dan while saya ga tw gimana bawa nilai 'n' dari php ke js..
tapi memang karna saya ga bisa js jadi saya ga bisa-bisa bos..
Mohon bos bos mengkoreksi javascript y saya, jangan2 emang js saya nya terlalu ngaco.. :(
Maaf bos vb_loph,saya numpang bertanya di c bos..tapi...
| vb_loph wrote: | | hlie wrote: | coba bikin 1 function js
function validation()
{
if(document.test.nama.value == '')
{
alert('asdsadsa');
return false;
}else{
return true;
}
}
<form name="test" action="" method="post" onsubmit="return validate();">
<input type=text name=nama >
....
....
nb : itu baru validasi awal buat front end, kl bs di validasi lg pas di php, jadi double secure..
|
yg saya buat sih kyk gini :
| Code: | <?php echo "<script>";
echo "konfirm=window.confirm('Anda Yakin Menyimpan Absen dengan Guru yang Berbeda?');";
echo "if(konfirm==true)";
echo "{";
echo "location.href ='DaftarHadir1.php?kelas=$kelas';";
echo "}";
echo "</script>"; ?> |
tapi yg saya bingung.. kalau saya menggunakan coding ini, saya ga bisa kirim data yg bentuknya array? |
@ bos hlie => script saya untuk perulangan input..
tapi js nya ga bisa muncul window confirm nya.. bos bos
@ bos vb_loph => mudah2n script saya menolong juga bos,
COZ c bos jg mw input data (record) berbentuk array.. _________________ :') |
|
| |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
|
|
|
Powered by phpBB © 2001, 2002 phpBB Group
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|