Results 1 to 8 of 8

Thread: Unable to create box with button click ...using Javascript

  1. #1
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Unable to create box with button click ...using Javascript

    hi
    i hav created 3 buttons
    MORE - is should generate a text box and combo box everytime it is clicked
    FEWER-is should delete a text box and combo box everytime it is clicked
    SHORTLIST- it should display the resul into anothe page

    I hav used JAVASCRIPT...

    The code is as follows :-

    function addRow(frmCriteria)
    {
    var tmp = frmCriteria.sub_cnt.value;
    tmp++;
    frmCriteria.sub_cnt.value = tmp;
    frmCriteria.action = "shortlist_by_cutoff.php?group="+frmCriteria.grp_id.value;
    }

    function removeRow(frmCriteria)
    {
    if( frmCriteria.sub_cnt.value > 1)
    {
    var tmp = frmCriteria.sub_cnt.value;
    tmp--;
    frmCriteria.sub_cnt.value = tmp;
    frmCriteria.action = "shortlist_by_cutoff.php?group="+frmCriteria.grp_id.value;
    }
    else
    {
    return false;

    }
    }


    the code inside form tag :-

    <form name="criteria_frm" action="shortlist_cutoff_act.php?group=$group" method="POST">

    <input type="hidden" name="grp_id" value="<?php echo $group;?>">

    **<input type="hidden" name="sub_cnt" value= ??> //it takes the value of tmp(javascripts) but i dnt knw how to sho the value

    <input type="submit" onclick="return addRow(document.criteria_frm)" value="More">
    <input type="submit" onclick="return removeRow(document.criteria_frm)" value="Fewer">

    <input type="submit" value="Shortlist" onclick="return DoSubmit(document.criteria_frm)">
    when i am executin is not giving desired result...
    waitin for the reply....

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Wanna link us to the page where this is in action? That'll be helpful in addition to the code.

  3. #3
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry i did not get ur answer...

  4. #4
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    He means post a link to YOUR website so we can see what is happening on it

  5. #5
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i dnt hav link... i am running it on localhost + its a part of my project that i am currently doing that deals with online candidate evaluation system...
    i hav got the solution for the problem...
    bt my new doubt is ..
    a hav a combobox that contains the name of the subjects...
    bt when i am clicking the MORE button the combo box is gettin created by data is not there in it...
    the code is as follows :-
    <script type="text/javascript">
    function insRow()
    {
    var x=document.getElementById('mytab').insertRow(0)
    var y=x.insertCell(0)
    var z=x.insertCell(1)
    var txt1=document.createElement("input");
    var txt2=document.createElement("select");
    txt1.size="5";
    y.appendChild(txt1);
    z.appendChild(txt2);
    }
    </script>
    the code inside form tag is :-

    <form name="chg" action="9.php" method="POST">
    <table cellspacing=2 cellpadding=2 border=1>
    <tr><th>col1</th></tr>
    <tr><td>
    <table>
    <tr>
    <th>head1</th>
    <th>head2</th>
    </tr>
    </table>
    </td></tr>
    <tr><td>
    <table id="mytab">
    <tr><td><input type="text" size=5 name="nam1"></td>
    <td><select name="nam2" id="sel">
    <option>java</option>
    <option>C++</option>
    <option>DS</option> </td>

    </tr>
    </table>

    </td></tr>
    <tr><td><input type="button" onclick="insRow()" name="but" value="ADD">
    </td></tr>
    </table>
    </form>
    how to rectify the error....
    Here i hav specified the data in combobox but actually the data is taken from
    Database using PHP tag... i am using postgreSQL as DB....
    if the above code work in creating combobox with the specified data there will not be problem with data take from DB...
    Waitin for the reply......

  6. #6
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i dnt hav link + its the project that i am doing that deals with candidate evaluation system...

    i hav got the solution for above mentioned problem..
    but my new doubt is...
    when i am clickin thr MORE button new combo box is gettin created but data is not there in it that was in 1st combo box...
    the code is as follows :-
    function insRow()
    {
    var x=document.getElementById('mytab').insertRow(0)
    var y=x.insertCell(0)
    var z=x.insertCell(1)
    var txt1=document.createElement("input");
    var txt2=document.createElement("select");
    txt1.size="5";
    y.appendChild(txt1);
    z.appendChild(txt2);
    }
    the code inside the form tag is :-
    <form name="chg" action="9.php" method="POST">
    <table cellspacing=2 cellpadding=2 border=1>
    <tr><th>col1</th></tr>
    <tr><td>
    <table>
    <tr>
    <th>head1</th>
    <th>head2</th>
    </tr>
    </table>
    </td></tr>
    <tr><td>
    <table id="mytab">
    <tr><td><input type="text" size=5 name="nam1"></td>
    <td><select name="nam2" id="sel">
    <option>java</option>
    <option>C++</option>
    <option>DS</option> </td>

    </tr>
    </table>
    </td></tr>
    <tr><td><input type="button" onclick="insRow()" name="but" value="ADD">
    </td></tr>
    </table>
    </form>
    here i hav inserted the data in combobox but actually the data is taken from DB and its inserted in combobox by using PHP tag....
    if the above code works then it will work for the DB code in PHP tag also...
    Waiting 4 the reply.......

  7. #7
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    try this

    function insRow()
    {
    var x=document.getElementById('mytab').insertRow(0)
    var y=x.insertCell(0)
    var z=x.insertCell(1)
    var txt1=document.createElement("input");
    var txt2=document.createElement("select");
    var txt3=document.createElement("option");
    txt1.size="5";
    y.appendChild(txt1);
    z.appendChild(txt2);
    txt2.options.add(txt3);
    txt3.innerText = "abc";
    txt3.value = "abc1";
    txt3.selected = "true";



    }

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    txt3.innerText = "abc";
    Not necessary and will error out in all but IE.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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