troubleshooting Question

Using innerHTML and retrieving values for PHP

Avatar of xedstr
xedstr asked on
PHP
9 Comments1 Solution375 ViewsLast Modified:
Hi,

I have created a form that uses a special Javascript -> this script creates HTML (innerHTML) on demand when the user wants to add something to a (option)list. If not used, the HTML-code will not be created. (Only if the user pushes the ADD-button after he had filled in a textbox, the value in the Textbox is moved to a listbox).

This code works fine, but I have the problem to retrieve the values in this optionlist because it is only generated dynamically.
I want to store the values in a table in MySQL.

Is there a way to get the values in this optionlist? Do you have any suggestions/solution to solve this problem?

Hereby the 3 functions in my Javascript :
function addOptions()
{
var url= document.CreateQuestion.URL.value;
var Item = document.CreateQuestion.nameLink.value;
var linkItem = url + "=" + Item;


if (isblank(url)|| isblank(Item))
      alert("You have to insert a URL and a name first!");
else
      {
         if (teller > 0)
        {
        teller=teller+1;
          var item = new Option(linkItem, "linkItem", false, false);
            var links = document.CreateQuestion.link
            links.options[links.options.length] = item;                        
        }
        
        if (teller == 0)
        {
           newCode();
          teller=teller+1;
          var item = new Option(linkItem, "linkItem", false, false);
          var links = document.CreateQuestion.link
          links.options[links.options.length] = item;      
        }
        document.CreateQuestion.nameLink.value="";
        document.CreateQuestion.URL.value="";
      }
}



function newCode()
{
      var code ="<br>"
            code +="<table>"
            code +="<tr>"
            code +="<th align=right>"
            code +="<td>"
            code +="<select name='link' size=5>"
            code +="</select>"
            code +="<input type='button' name='removeLink' value='Remove' onclick='removeOptions()'>"

            code +="</table>";
      
      document.getElementById("list").innerHTML=code      
}

function removeOptions()
{
      var i = document.CreateQuestion.link.selectedIndex;
      if (i>=0){document.CreateQuestion.link.options[i] = null;}
}
 
ASKER CERTIFIED SOLUTION
harwantgrewal

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros