www.webdeveloper.com
Results 1 to 6 of 6

Thread: I need a JavaScript, please could you help?

  1. #1
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64

    I need a JavaScript, please could you help?

    Hello,

    See: http://awesomescreenshot.com/0a3mle7e9
    PHP Code:
          <?php
          
    while ($row mysql_fetch_array($receiverler)) {
          
    ?>
        <tr>
          <td class="table_body2" width="30%"><?=$row['receiver_markasi']?></td>
          <td class="table_body2" width="27%"><?=$row['receiver_tipi']?></td>
          <td class="table_body2" width="26%"><?=$row['receiver_ozelligi']?></td>
          <td class="table_body2" width="8%"><?=@$row['receiver_fiyati']?><?=@$row['receiver_para_cinsi']?></td>
          <td class="table_body2" width="9%">
          <input type="checkbox" name="secilenreceivermarka_id[]" value="<?=$row['id']?>">
          </td>
          <td class="table_body2" width="9%">
            <select size="1" name="secilen_receiver_sayisi[]">
            <option></option>
            <?php
            $sayi 
    1;
            while(
    $sayi $encok=$dairesayisi['secilen_daire_sayisi']+1) {
            echo 
    '<option value="'.$sayi.'">'.$sayi.'</option>';
            
    $sayi++;
            }
           
    ?>
          </select>
          </td>
        </tr>
        <?php
         
    }
         
    ?>
    Product may be 1 row or more rows

    Rules:
    1. Whole selects are disabled by default.
    2. If you choose checkbox, select is enabled and you have to the amount of product. alert("Select the amount of your product or deselect the checkbox").
    3. If you choose th amount of products, The amount must be max 10 - for whole selects. alert("The amount of product cannot be more than 10").
    4. You can choose 3 different product. alert("You can select up to 3 different products")


    Best Regards
    Thanks

    Adem
    Last edited by Adem; 11-16-2012 at 07:24 AM.

  2. #2
    Join Date
    Nov 2012
    Location
    Bangalore
    Posts
    5
    Let us assume your checkboxes are named as 'mycheck1,mycheck2,mycheck3,mycheck4' and select boxes as 'myselect1,myselect2,myselect3,myselect4'.

    <input type="checkbox" id="mycheck1" name="mycheck1" onclick="javascript:sel(this);"/>

    <select size="1" id="myselect1" name="myselect1" onclick="javascript:checkme(this);"><option value=""></option><option value="5">5</option></select>


    <script type="text/javascript">
    var checkBoxCount = 4,tempSum=0,globalValidationFlag=false;
    function sel(ele){
    alert('Please choose an amount');
    }

    function checkme(ele){
    var emptyBox = false;
    globalValidationFlag=false;

    for(var i=1;i<=checkBoxCount;i++){
    if(document.getElementById('mycheck'+i).checked){

    if(!isNaN(document.getElementById('myselect'+i).value)){
    tempSum+=eval(document.getElementById('mycheck'+i).value);
    }else{
    emptyBox = true;
    alert('Choose an value in select box'+i); //Checks if select box is chosen no value
    break;
    }

    }//End If
    }//End for

    if(tempSum>10){alert('Amount exceeded 10');}else if(!emptyBox){globalValidationFlag=true;}

    }

    Based on 'globalValidationFlag' value you may (if true) submit your form or discard it.

    </script>

  3. #3
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64
    Thank you so much for your help.

    But it is not I wanted.

    1. "All selects" must be disabled.
    2. When the checkboxes are enabled and the person doesnot select the amount of product, it gives the alert at that moment while he/she is selecting. But I want that it gives the alert when the person finishes her/his choices and clicks "submit".
    It gives pass even though the person doesnot select the amount. It musn't be that.
    3. If you choose th amount of products, The amount must be max 10 - for whole selects. alert("The amount of product cannot be more than 10").
    4. You can choose 3 different product. alert("You can select up to 3 different products")


    Please Could you help me?

    Best Regards
    Thank you
    Adem

  4. #4
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64
    Hello again,

    Everything is all right.
    But have a problem.
    Global total is not running.

    What could be the problem?
    Could you help me?

    Thanks

    See: http://awesomescreenshot.com/004ne0pd6
    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><?=$dairesayisi?>||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 <?=$dairesayisi?> adet geÁmemeniz gerekiyor.");

    return false;
    }
    }
    return true;
    }
    </script>

  5. #5
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64

  6. #6
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64
    Hello again,

    The rule : The amount of products can be max 21(sample).

    This JavaScript gives a warning about rule above for one value.

    I want that;

    The JavaScript must give a warning for total choosing values.
    1. value="5"
    2. value="10"
    3. value="8"
    =23 are great than 21. (It must give a warning)

    Thanks

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
  •  
HTML5 Development Center



Recent Articles