Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with a dynamically created text box, submitting values

Status
Not open for further replies.

joline

Programmer
Feb 17, 2007
1
US
Hi!
I've looked around for other people who've had this problem, but the answers I've seen don't really apply to the code I've written and I could really use some help.

I have a form that dynamically creates a textbox using:

<html><select name='sporty' id = 'sport' onclick= answer(this.options[this.selectedIndex].value)></html>

the function - answer - takes the value and calls another function:

<script type="text/javascript">
function OtherIndivAnswer()
{
var IntPath = document.signup.position;
var TheOptions = IntPath.options.length;

document.signup.position.options.length = 0;

IntPath.options[IntPath.options.length] = new Option('N/A','NULL');

document.getElementById("cell").innerHTML = "<div id=\"myDiv\"><font face=\"Arial, Helvetica, sans-serif\" color=\"#ff00ff\">Enter Sport:</font></div>";

document.getElementById("cell2").innerHTML = "<div id=\"myDiv\"><input type = \"text\" name = \"other_sport\" maxlength=\"100\"/></div>";
}
</script>

What I need to do is somehow get the value from cell2 to pass when the form is submitted to my php script. I've confirmed that the value is not in $HTTP_POST_VARS.

My only real idea is to pass it as a hidden value, but when I added the following lines to function OtherIndivAnswer()

<script type="text/javascript">

var the_sport =document.getElementById("cell2").value;

document.signup.write('<input type="hidden" name="the_sport" value="' + the_sport + '">');

</script>


nothing really changed.

If anyone could help I'd really appreciate it - I didn't post the entire script because it is huge, but if someone wanted to see it in full, I'll go ahead and do that.
 
I ignore all the rest, mainly because I don't know what are the purposes, other than the question asked, namely, to create the input.

>document.getElementById("cell2").innerHTML = "<div id=\"myDiv\"><input type = \"text\" name = \"other_sport\" maxlength=\"100\"/></div>";
[tt]
var odiv=document.createElement("div");
odiv.name="myDiv";
var oelem=document.createElement("input");
oelem.type="text";
oelem.name="other_sport";
oelem.maxLength="15";
odiv.appendChild(oelem);
document.getElementById("cell").appendChild(odiv);
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top