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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    avoid control overwrite itself jquery

    hi all,
    I am trying to create runtime controls but when control comes from anothe page. they are overwriting itself...
    my code is :


    <script src="include/jquery-1.2.6.min.js"></script>
    <script type="text/javascript">

    $(document).ready(function(){


    //phone no.
    $("#add_phone").click(function(){

    $.post("ajax1.asp",{action:'phonepost',pid:<%=Request("pid")%>},function(msg){

    $("#phone_output").html(msg);
    $("#phone_output").load("ajax1.asp?pid=<%=Request("pid")%>&action=viewphone");

    });

    });


    });

    </script>


    and code from the control comes:


    <%
    if Request("action") ="phonepost" then
    per_id=Request("pid")
    end if
    if Request("action") ="phonepost" or Request("action")="viewphone" then
    %>
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td width="80%"><input type="text<%=per_id%>" size="60" value="Enter Phone" name="textfield" onclick="if(this.value=='Enter Phone')this.value='';" onblur="if(this.value=='')this.value='Enter Phone';" /></td>
    <td width="17%" align="left"><select id="Phone_relation" name="Phone_relation<%=per_id%>">
    <option value="Work" selected="selected">Work</option>
    <option value="Mobile">Mobile</option>
    <option value="Fax">Fax</option>
    <option value="Home">Home</option>
    </select></td>
    <td width="3%" align="right"><a href="?action=delete&id=<%=per_id%>&pid=<%=per_id%>"><img src="images/remove.gif" style="cursorointer" title="Delete" id="btn_delete" border="0"/></a></td>
    </tr>
    </table>

    <%
    response.write "<br>"
    end if
    %>



    plz help....

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    Wheeling, IL
    Posts
    358
    Thanks
    5
    Thanked 62 Times in 60 Posts
    If I'm reading this correctly... you're losing the 'click' event assigned to $("#add_phone") when the ajax call completes? Mind you, using code tags within your post is a good idea... for instance, you don't get smilies in the middle of the code itself. :P

    Anyways... a solution:

    Code:
    $("#add_phone").live('click', function() {
    // Stick what to do upon click here
    })
    See if that works for you.
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Eldarrion View Post
    If I'm reading this correctly... you're losing the 'click' event assigned to $("#add_phone") when the ajax call completes? Mind you, using code tags within your post is a good idea... for instance, you don't get smilies in the middle of the code itself. :P

    Anyways... a solution:

    Code:
    $("#add_phone").live('click', function() {
    // Stick what to do upon click here
    })
    See if that works for you.
    thanks


  •  

    Posting Permissions

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