Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:39:38+00:00 2026-06-01T14:39:38+00:00

I’m not finding any question specifically with the odd problem I have. Basically I’ve

  • 0

I’m not finding any question specifically with the odd problem I have. Basically I’ve got a form set up for inputting a users phone number and extension. I’ve made an Add button so I can add more phone/extensions to the form. I’ve got the adding working fine in the form and also for the SQL code. The problem is removing the form AND the SQL code. You can see in the code that each new entry has its own “Remove” link which holds the DIV info for that particular one. And it goes to a “remove” function which takes that one out. It works fine for the form, but it doesn’t do anything for the SQL code. I’ve created something similar for the SQL code so I have a function that will remove it. And just to test I put in the same “Remove” href as the forms, and if I click the link for the SQL portion it does remove it.
So I’m trying to find a way to click the Remove link on the form portion and have it take out that particular form and the corresponding SQL code.
I’ve toyed with the idea of trying to grab a Name from the form DIV which matches the DIV name of the SQL portion, but I can’t seem to get that to work.

    ////
    //-------------Add Phone Form----------------
    ////

    function addElement() { 

    var ni = document.getElementById('phoneDiv'); 
    var numi = document.getElementById('theValue'); 
    var num = (document.getElementById('theValue').value -1 + 2); 
    numi.value = num; 
    var newdiv = document.createElement('div'); 
    var divIdName = 'phoneDiv'+num+''; 
    var sqlDivIdName = 'SQL'+divIdName+'';
    newdiv.setAttribute('id',divIdName); 
    newdiv.innerHTML = '<input type=hidden id=' + num + ' name='+sqlDivIdName+' value='        + num + '><a href="javascript:remove('+divIdName+')">Remove</a> <tr><td>Phone Number:</td>  <td> <input type="text" name="phone' + num + '" maxlength="10"> </td></tr> <tr>  <td>Extension:</td><td> <input type="text" name="ext' + num +'" maxlength="5" value="00000">'; 
    ni.appendChild(newdiv); 

    javascript:addElement2(); 
    } 

    ////
    //-------------Add Phone SQL----------------
    ////

    function addElement2() {

var ni = document.getElementById('SQLphoneDiv'); 
    var numi = document.getElementById('theValue2'); 
    var num = (document.getElementById('theValue2').value -1 + 2); 
    numi.value = num; 
    var newdiv = document.createElement('div'); 
    var divIdName = 'SQLphoneDiv'+num+''; 
    newdiv.setAttribute('id',divIdName); 
    newdiv.innerHTML = '<input type=hidden id=' +num+ ' value=' +num+ '><a         href="javascript:removeSQL('+divIdName+')">Remove</a> $insert_phone = "INSERT INTO phone (Phone_Cust_ID,Phone_Numb,Ext) VALUES (\'$cust_ID[0]\',\'".$_POST[\'phone' +num+ '\']."\',\'".$_POST[\'ext' +num+ '\']."\')"; $add_phone = mysql_query($insert_phone);'; 
    ni.appendChild(newdiv); 
    }


    ////
    //-------------Remove Phone Form----------------
    ////

    function remove(xy) {
    var ni = document.getElementById('phoneDiv'); 


    ni.removeChild(xy);

    }


    ////
    //-------------Remove Phone SQL----------------
    ////

    function removeSQL(yz) {
    var ni = document.getElementById('SQLphoneDiv'); 
    ni.removeChild(yz);

    }

I’ve tried to use just one remove function instead of two, or to make the first remove function trigger the second, but I think the problem is that I can’t get the +divName+ information on the SQL portion for the child I’m trying to remove.

I’m very new to JavaScript so I’m sure jQuery has a very simple way to do this, but jQuery is confusing to me right now since I’m still trying to grasp most of the concepts in JavaScript alone.
Thanks for any tips I can get.

Also, I know the SQL isn’t really correct but I’m not worried about that right now. Once I get this function to work then I can clean everything up.

Nathan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:39:39+00:00Added an answer on June 1, 2026 at 2:39 pm

    You can store the SQLphoneDiv element id in your phoneDiv element by doing the following inside your addElement function

    newdiv.sqlDivId = sqlDivIdName
    

    Then in your remove function do

    var sqlDiv = document.getElementById(xy.sqlDivId);
    var sqlNi = document.getElementById('SQLphoneDiv');
    sqlNi.removeChild(sqlDiv);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.