Jump to content

Recommended Posts

Soulstealer, what is this all about?

var obj;
obj = document.getElementById(form_id);
for(i=0;i<obj.length;i++) {
	/*alert(obj[i]);*/
	if (obj[i].tagName == "INPUT") {
		if (obj[i].type == "text") {
			getstr +=obj[i].name+"="+obj[i].value+"&";
		}
		else if(obj[i].type == "hidden") {
			getstr +=obj[i].name+"="+obj[i].value+"&";
		}
	}
	else if(obj[i].tagName == "SELECT") {
		var sel = obj[i];
		getstr +=sel.name +"="+ sel.options[sel.selectedIndex].value + "&";
	}
}

 

If you're getting an element by ID, why would you loop? There should ALWAYS be one entry.

Link to comment
https://forums.phpfreaks.com/topic/156412-live-chat/#findComment-823987
Share on other sites

@Ken2k7

 

Where is your chatroom? I'm not suggesting that Soulstealer's approach is the best, but it's easy to criticize from the bench.

 

@poornima

 

Unless there is a good reason to build this yourself why not leverage something that is already built. No point reinventing the wheel here.

Link to comment
https://forums.phpfreaks.com/topic/156412-live-chat/#findComment-824889
Share on other sites

@Ken2k7

 

Where is your chatroom? I'm not suggesting that Soulstealer's approach is the best, but it's easy to criticize from the bench.

I need a chatroom for show just to say that you shouldn't have more than one HTML element with the same ID on the same page? Well in that case, I'll post links to pages that say that in the future. How's that?

Link to comment
https://forums.phpfreaks.com/topic/156412-live-chat/#findComment-825102
Share on other sites

Not necessary, and I'm not saying you're comment was inaccurate... just lose references like this:

 

Wow, learn xHTML will ya?

 

It puts people on the defensive. A more productive approach would have been something like:

 

Nice job on building this as a proof of concept. I would caution however that using the same ID for multiple elements is not a good practice. You could improve it by...

 

Not interested in arguing with you, just please be careful how you approach people. We want to keep these forums a productive place so that the community grows. That's really all I'm encouraging.

Link to comment
https://forums.phpfreaks.com/topic/156412-live-chat/#findComment-826419
Share on other sites

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.