Jump to content

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()" />

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.