Jump to content

Dynamic Form Variables...


lordphate

Recommended Posts

Hey everyone,

 

I had a quick question, what would be the best way to implode dynamically generated textfields [generated through ajax]. The dynamic textfield would have a "name"+ count

 

<input type="textfield" name="textfield0"...

 

Basically i'm wanting to implode each "textfield#" seperated by || or something close to that.

 

I was thinking a foreach ? But then i can't figure out how to get the number of textfields :(

 

Any help would be appreciated [bTW i'm not looking for the actual answer, just a suggestion on how to go about doing this, i'm trying to learn ajax, and it's through me for a loop ;) ]

Link to comment
https://forums.phpfreaks.com/topic/148026-dynamic-form-variables/
Share on other sites

<script type="text/javascript">
function doal() {
	var d = document;
	var a = d.getElementsByTagName("input");
	for (i in a) {
		if (a[i].name.indexOf("number") >= 0) alert(a[i].name);
	}
}
</script>
<form name="rawr">
<input type="text" name="number0" />
<input type="text" name="number1" />
<input type="text" name="number2" />
<input type="text" name="number3" />
</form>
<input type="button" onclick="doal()" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.