Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If checkbox is checked, then ... [need some help]

    heya folks, I am looking for solution to my problem for some time, but I didn't have any luck. I would be extremly greatefull if anybody could help me.

    Here is my problem:

    In the first form I have a textbox and a link. When I click to a link, then a new form (html) is open. There is a list of some variables with a checkboxes.
    Now here is a catch. I want to checked some "variables checkboxes" and then I want to update all checked variables into first form textbox.

    for example:
    form2 where I have
    var1=100, var2=200, var3=30, var4=55

    var1 [] <-this is checkbox
    var2 []
    var3 []
    var4 []
    Now I checked var1, var2 and var4.
    And now I need a function that look witch variables are checked, and group that variables into a string with separator ( and update that string into my first page(form)
    Now textbox in first page should have value like this-> 100;200;55

    I hope you understand what I want, and I am sure some of you could have the solution for my problem.

    thanx in advance
    MAXX
    Last edited by MAXX; 04-07-2003 at 11:05 AM.

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    .....and group that variables into a string with separator [ ; ]

    well this is a separator, and not a smiling face like above

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    heya java masters

    well, looks like nobody reply, but I think that this shouldn't be a problem for you guys, so please help me

    I found a script that should check all checkboxes on the page:
    // Description:To check all check boxes on the web page
    -------------
    function gCheckAll(chk)
    {
    for (var i=0;i < document.forms[0].elements.length;i++)
    {
    var e = document.forms[0].elements[i];
    if (e.type == "checkbox")
    {
    e.checked = chk.checked
    }
    }
    }
    --------------------

    and now I need to update that code -> for every checkbox that is checked, take the value, and add the value to a string, separated with [;].

    If anybody have the solution, please help
    thanx in advance
    maxx

  • #4
    New Coder
    Join Date
    Jan 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is my code:


    ---------------------------------------------------
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <title>Őifrant modulov</title>
    <meta name="GENERATOR" content="Microsoft FrontPage 3.0">

    <script language="JavaScript">
    function getValues(f)
    {
    var el,e=0,i,cnt, newItem='';
    f=document.frmChk;
    while(el=f.elements[e++])
    {
    if(el.type=='checkbox' || el.type=='radio')
    {
    if(el.checked)
    {
    cnt=[el.value];
    var i = 0;
    while(el=cnt[i++])
    newItem = newItem + el;
    }
    }
    }
    {
    window.opener.document.VNOS.MO.value = newItem;
    window.close();
    }
    }
    </script>
    </head>

    <body style="font-family: Arial">

    <form action="http://maxx.agis.si/scripts/mgrqcgi.exe" method="POST" name="frmChk" target="_self">
    <input type="hidden" name="APPNAME" value="priklop">
    <input type="hidden" name="PRGNAME" value="PR_SIMO_01_B_K">
    <input type="hidden" name="ARGUMENTS" value="POLJE,T1,G1,T2,T3,e">
    <input type="hidden" name="POLJE" value="MO">
    <input type="hidden" name="G1" value="VNOS">

    <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr>
    <td width="100%"><small><font color="#0000FF"><strong>VpiÜi kriterij za iskanje modula: <input type="submit" value="Potrdi" name="B1"></font></strong></small></td>
    </tr>
    </table>
    <table border="1" cellspacing="0" cellpadding="0" width="100%">
    <tr>
    <td width="05%"><small><font color="#000000"><input type="text" name="T1" size="5" maxlength="5" value="P"></font></small></td>
    <td width="80%"><small><font color="#000000"><input type="text" name="T2" size="50" maxlength="50" value=""></font></small></td>
    <td width="05%"><small><font color="#000000"><input type="text" name="T3" size="5" maxlength="5" value=""></font></small></td>
    <td width="10%"><input type="button" value="Prenesi" name="B2" onclick="getValues();"></td>
    </tr> <tr>
    <td width="05%"><small><font color="#000000"><strong>Modul</strong></font></small></td>
    <td width="80%"><small><font color="#000000"><strong>Opis</strong></font></small></td>
    <td width="05%" align="center"><small><font color="#000000"><strong>Aplikacija</strong></font></small></td>
    <td width="10%" align="center"><small><font color="#000000"><strong>Izberi</strong></font></small></td>
    </tr>
    <tr>
    <td width="05%"><small><a href="javascript:Update('PF')">PF</a></small></td>
    <td width="80%"><small>PREJETI DOKUMENTI</small></td>
    <td width="05%" align="center"><small>FIN</small></td>
    <td width="10%" align="center"><small><input type="checkbox" name="chk" value="PF"></small></td>
    </tr>
    <tr>
    <td width="05%"><small><a href="javascript:Update('PN')">PN</a></small></td>
    <td width="80%"><small>POTNI NALOGI</small></td>
    <td width="05%" align="center"><small>FIN</small></td>
    <td width="10%" align="center"><small><input type="checkbox" name="chk" value="PN"></small></td>
    </tr>
    <tr>
    <td width="05%"><small><a href="javascript:Update('PROJ')">PROJ</a></small></td>
    <td width="80%"><small>PROJEKTI</small></td>
    <td width="05%" align="center"><small>FIN</small></td>
    <td width="10%" align="center"><small><input type="checkbox" name="chk" value="PROJ"></small></td>
    </tr>
    </table>
    </form>

    <script language="JavaScript">
    <!--
    function Update(newItem)
    {
    window.opener.document.VNOS.MO.value = newItem;
    window.close();
    }
    //-->
    </script>
    </body>
    </html>
    ---------------------------------------------------

    note:
    function Update(newItem) <- before I used that function to get one parameter, to my parent page

    now I try with
    function getValues(f)

    to see which checkbox are checked, and make a string with checked variables

    any idea why it doesn't work
    thanx

  • #5
    New Coder
    Join Date
    Jan 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    problem solved, thanx anyway ...

    so this is working code, that check all checkboxes on the child-page, and create a string with [;] for each selected checkbox

    ----------------------------------------------------
    <script language="JavaScript">
    function getValues(f)
    {
    var el,e=0,i,cnt, newItem='';
    f=document.frmChk;
    while(el=f.elements[e++])
    {
    if(el.type=='checkbox' || el.type=='radio')
    {
    if(el.checked)
    {
    cnt=[el.value];
    var i = 0;
    while(el=cnt[i++])
    newItem = newItem + el +';';
    }
    }
    }
    window.opener.document.VNOS.MO.value = newItem;
    window.close();
    }
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •