Results 1 to 4 of 4

Thread: How to get onclick value from button which is there in hidden div?

  1. #1
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to get onclick value from button which is there in hidden div?

    Hi All, i am veera. i have one hidden div which has ok and cancel button. i have kept this in showmydiv.html file. i have another file called upload.html which has one button to upload a file. on onclick of upload-button(onclick=confirmsubmit(); )..in this confirmsubmit(), i am calling another function to enable hidden div in javascript. like

    confirmsubmit()
    {

    var x=showmydiv(divid);
    alert("div popup");
    .........
    .........

    }

    when i click on the upload button, i am able to get the div visible but the problem is the flow of execution does not stoped till click ok or cancel in div popup.

    i would like to stop the flow till click either ok or cancel.when i click ok or cancel then the next statement (ex:alet("div popup"); ) has to execute.
    when i click on OK it has to come back to called place with return true and cancel has to return false....please help me..

    Thank you

    sample code:
    showmydiv.html:
    <div id="dividv" class="popup">

    <table border="0" height="130px" cellspacing="0" cellpadding="0" class="border-table">
    <tbody style="background: #ffffff">
    <tr border="0" bgcolor="#ACC6DF" height="22px">
    <td align="left" valign="center" style="font-family: arial;font-size: 12px; padding-left: 5px;" id="hdMsg"> Delete
    </td>
    <td align="right" valign="center">
    <a href="#" class="poplink" onclick="hidemydiv('divid');return false;" id="link">
    <img src="delete.gif" border="0"></a></td>
    </tr>
    <tr>
    <td style="padding-top: 15px; padding-bottom: 10px;">
    <table width="100%">
    <tr>
    <td width="40%" style="padding-left: 10px;" align="center" >
    <input id="YesBtn" type="button" name="page" style="cursor: pointer;" value="OK" class="button">
    &nbsp;
    <input type="button" name="page" style="cursor: pointer;" value="Cancel" class="button" id="NoBtn">
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </tbody>
    </table>
    </div>

    Showdiv.js:
    function showmydiv(divid)
    {
    var divobj = document.getElementById(divid);
    divobj.style.display = "none";
    return true;
    // break;
    }

    upload.html

    <td align="center" valign="top" colspan="3" style="padding-top: 10px; padding-left:10px;">

    <a href="#" onClick="if (confirmSubmit()) document.config_backup_restore.submit();" id="restore-link" name="restore-link" class="button" title=""></a>
    </td>


    the above code is for reference...

  2. #2
    Join Date
    Sep 2008
    Posts
    119
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    are you trying to put in a confirmation box that returns a value?

    Code:
    <script type="text/javascript">
    function get_return_value()
    {if (confirm('Please click ok or cancel.')) {return true;};}
    
    return_val = get_return_value();
    
    switch(return_val)
    {
    case true:
    alert('you clicked ok');
    //document.getElementById('whatever').display ='';
    break;
    }
    </script>
    document.write is document.wrong

  3. #3
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    HI Falkon303,

    Thank you for your replay. i am not using any confirm or alerts. actually my requirement replacing the alert or confirm boxs. as i explained in previous message, when i click on the button which is in divpop , it needs to return the value to showmydiv(divid). this has to wait for return value from OK or cancel button.

  4. #4
    Join Date
    Sep 2008
    Posts
    119
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    You want to send the value *before* you apply a "display:none;" attribute, or the element won't be seen as existing.
    document.write is document.wrong

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
  •