I need help for a feature
Hello,
My code:
PHP Code:
<script type="text/javascript">
function baslangic(status)
{
status=!status;
textler=document.getElementsByName("secilen_receiver_sayisi[]");
for(x=0;x<textler.length;x++){
textler[x].disabled = status;
}
}
function isaretle(){
marka=document.getElementsByName("secilenreceivermarka_id[]");
sayi=document.getElementsByName("secilen_receiver_sayisi[]");
for(x=0;x<marka.length;x++){
sayi[x].disabled=!marka[x].checked;
}
}
function kontrol(){
marka=document.getElementsByName("secilenreceivermarka_id[]");
sayi=document.getElementsByName("secilen_receiver_sayisi[]");
for(x=0;x<marka.length;x++){
if(marka[x].checked==true&&(sayi[x].value><?=$maximum_receiver?> ||sayi[x].value==""||sayi[x].value<1||sayi[x].value.search(/\d/g)<0)){
alert("Receiver seçme isteğe bağlıdır.\n\nEğer bir marka seçtiniz ise miktarıda seçmelisiniz ve toplam daire sayınız olan <?=$maximum_receiver?> adet geçmemeniz gerekiyor.");
return false;
}
}
return true;
}
</script>
This is the name of Checkbox : name="secilenreceivermarka_id[]"
This is the name of Select list: name="secilen_receiver_sayisi[]"
Maximum amount variable: <?=$maximum_receiver?>
1st rule: http://awesomescreenshot.com/0a1o6rh36 by DEFAULT, No problem
2nd rule: http://awesomescreenshot.com/07ao6s6c2 Required select amount, No problem
3th rule: http://awesomescreenshot.com/0beo6tmec There is not this future , I want to add this future in code above.
Could you help me?
All the rules are these.
Thank you
I would use a function similar to your baslangic() one above, but as you look through the elements, increment a variable with the value of the selected option:
Code:
function get_total()
{
textler=document.getElementsByName("secilen_receiver_sayisi[]");
total = 0;
for(x=0;x<textler.length;x++)
{
total += parseInt(textler[x].value);
}
}
You might want to test on a few different browsers, I'm not sure if any of them will include the value from a select list that's been disabled (they won't post the values to the server, but they may still make them available to Javascript). If this is the case, then just add a check to see if this select list is disabled or not before incrementing the total variable.
Answer and for your help, thank you very much.
I'm beginner
Here HTML files, can you please help: http://www.teklif.uzayforum.com/files.zip
Best Regards
Adem GENÇ
Senior Member
What part did you not understand? We can help explain it.
(Or are you really just asking for someone to do it for you?)
Hello
I'm sorry, my english is bad
I am a very rookie
I would like to help one of the
Please can help?
I still have a problem
http://www.teklif.uzayforum.com/files.zip
Thanks
Senior Member
If you want help , we're happy to help. Please explain which part you're having trouble with.
If you want someone to do the work for you , you should probably be looking for someone to hire.
I do not know english, I do understand very little English
The problem is only, To collect all amounts
<form method="POST">
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]">
<input type="submit" value="Submit">
</form>
Sample: Max limit: 10
Sample:
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]"> 2
<input type="text" name="secilen_receiver_sayisi[]"> 4
<input type="text" name="secilen_receiver_sayisi[]"> 3
<input type="text" name="secilen_receiver_sayisi[]">
<input type="text" name="secilen_receiver_sayisi[]"> 3
alert("Total max allowed: 10");
that's the problem
Thanks
That's not really a question, but the example code I gave you would help you to decided when to use an alert() message.
Hello,
@ Ashley Sheridan, Thank you
But, I'm sorry, my English is bad, and I do not understand English
Request please, Can you tell us a bit more detail?
Sample: Max limit: 10
PHP Code:
< form method = "POST" onsubmit = "return kontrol()" > < input type = "text" name = "secilen_receiver_sayisi[]" > < input type = "text" name = "secilen_receiver_sayisi[]" > 2 < input type = "text" name = "secilen_receiver_sayisi[]" > 4 < input type = "text" name = "secilen_receiver_sayisi[]" > 3 < input type = "text" name = "secilen_receiver_sayisi[]" > < input type = "text" name = "secilen_receiver_sayisi[]" > 3 < input type = "submit" value = "Submit" >
Total: 12
alert("Total max allowed: 10");
Please
Thanks
Adem
Senior Member
You'll need to check the amounts (values) of each relevant input and then sum them. I'll put together an example this afternoon.
Also, it's not a problem if you don't speak English well. We can work with that.
@traq, Thank you very much
Example Waiting
My codes
PHP Code:
<?php
$i = 0 ;
while ( $row = mysql_fetch_assoc ( $receiverler )) {
if( $i % 2 ) {
$bgcolor = "#F0F1F9" ;
}else{
$bgcolor = "#DCDEF1" ;
}
?>
<tr class="table_body22" bgcolor="<?=$bgcolor?> ">
<td><?=$row [ 'receiver_markasi' ] ?> </td>
<td><?=$row [ 'receiver_tipi' ] ?> </td>
<td><?=$row [ 'receiver_ozelligi' ] ?> </td>
<td><?= @ $row [ 'receiver_fiyati' ] ?><?= @ $row [ 'receiver_para_cinsi' ] ?> </td>
<td>
<input type="checkbox" name="secilenreceivermarka_id[]" onclick="isaretle()" value="<?=$row [ 'id' ] ?> ">
</td>
<td>
<select size="1" name="secilen_receiver_sayisi[]">
<option value=""></option>
<?php
$sayi = 1 ;
while( $sayi < $encok = $dairesayisi + 1 ){
echo '<option value="' . $sayi . '">' . $sayi . '</option>' ;
$sayi ++;
}
?>
</select>
</td>
</tr>
<?php
$i ++;
}
?>
Thank you in advance
Hello again,
function kontrol() {
PHP Code:
function kontrol(){
marka=document.getElementsByName("secilenreceivermarka_id[]");
sayi=document.getElementsByName("secilen_receiver_sayisi[]");
for(x=0;x<marka.length;x++){
if(marka[x].checked==true&&(sayi[x].value><?=$maximum_receiver?> ||sayi[x].value==""||sayi[x].value<1||sayi[x].value.search(/\d/g)<0)){
alert("Receiver seçme isteğe bağlıdır.\n\nEğer bir marka seçtiniz ise miktarıda seçmelisiniz ve toplam daire sayınız olan <?=$maximum_receiver?> adet geçmemeniz gerekiyor.");
return false;
}
}
return true;
}
function kontrol() {
PHP Code:
< script language = "javascript" >
function kontrol (){
var arr = document . getElementsByName ( 'secilen_receiver_sayisi[]' );
var tot = 0 ;
for(var i = 0 ; i < arr . length ; i ++){
if( parseInt ( arr [ i ]. value ))
tot += parseInt ( arr [ i ]. value );
}
if( tot > 10 ){
alert ( "aaaa " + tot + " aaaa" );
return false ;
}
document . getElementById ( 'total' ). value = tot ;
}
</script>
This problem:
<form method="POST" action="next.php" onsubmit="return kontrol() ">
How to avoid conflict?
Thanks
You could name the functions differently? The exact naming doesn't matter so much, just as long as you can look at it in the future and understand what the function was for.
You did not write a sample code
However, I would like to thank everyone for everything.
is working perfectly
PHP Code:
<script type="text/javascript"> function baslangic(status) { status=!status; textler=document.getElementsByName("secilen_receiver_sayisi[]"); for(x=0;x<textler.length;x++){ textler[x].disabled = status; } } function isaretle(){ marka=document.getElementsByName("secilenreceivermarka_id[]"); sayi=document.getElementsByName("secilen_receiver_sayisi[]"); for(x=0;x<marka.length;x++){ sayi[x].disabled=!marka[x].checked; } } function kontrol(){ marka=document.getElementsByName("secilenreceivermarka_id[]"); sayi=document.getElementsByName("secilen_receiver_sayisi[]"); for(x=0;x<marka.length;x++){ if(marka[x].checked==true&&(sayi[x].value=="")){ alert("Receiver seçme isteğe bağlıdır.\n\nLütfen işaretlediğiniz kutuda receiver adedi seçiniz veya kutu seçimini kaldırınız."); return false; } } var arr = document.getElementsByName('secilen_receiver_sayisi[]'); var tot=0; for(var i=0;i<arr.length;i++){ if(parseInt(arr[i].value)) tot += parseInt(arr[i].value); } document.getElementById('total').value = tot; if(tot><?=$dairesayisi?> ){ alert("Toplam izin verilen receiver sayısı <?=$dairesayisi?> adettir.\n\nSiz toplam "+tot+" adet seçtiniz. Lütfen <?=$dairesayisi?> adedi geçmeyiniz."); return false; } return true; } </script>
I am going to ask you a help again. A simple thing for you
Thank you again to everyone
Best Regards
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks