Click here to Skip to main content
15,887,325 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: IIS 5.1 SMTP virtual Server doesn't show in inetmgr Pin
Yusuf18-Mar-09 17:10
Yusuf18-Mar-09 17:10 
QuestionHow to come in google's first page in my website.. Pin
D.Manivelan16-Mar-09 20:39
D.Manivelan16-Mar-09 20:39 
AnswerRe: How to come in google's first page in my website.. Pin
SeMartens16-Mar-09 23:13
SeMartens16-Mar-09 23:13 
GeneralRe: How to come in google's first page in my website.. Pin
D.Manivelan16-Mar-09 23:26
D.Manivelan16-Mar-09 23:26 
GeneralRe: How to come in google's first page in my website.. Pin
SeMartens16-Mar-09 23:29
SeMartens16-Mar-09 23:29 
GeneralRe: How to come in google's first page in my website.. Pin
D.Manivelan16-Mar-09 23:45
D.Manivelan16-Mar-09 23:45 
QuestionUsing Flash to drag and drop files Pin
Jason Sachan16-Mar-09 12:00
Jason Sachan16-Mar-09 12:00 
QuestionJavascript - Dynamic arrays Pin
Bryant May16-Mar-09 7:34
Bryant May16-Mar-09 7:34 
Hi everyone,

Im hoping someone can help me out here before I have a nervous breakdown...

Im trying to create a dynamic array of items which have been passed through from a php form. The script is designed to check that each of the form fields have been completed, return an error message if they havent and then enter them in to an array. The array is to then be passed to another PHP script for other things to be done to it.

The part Im stuck on is the creation of the array key. This needs to be done in a way that allows me to add the form field name as the key and the value of the form field as the array value so something like: "array[firstname] = Bryant;"

At the moment I have this all being done in the middle of a for loop which is iterating through the form fields to see if they have been completed. The code for this is below.

function submitForm(form, messageDiv, action)
{
	var targetDiv = document.getElementById(messageDiv);
	var inputs = document.forms[form].getElementsByTagName("input");
	var selects = document.forms[form].getElementsByTagName("select");
	var fieldName = document.getElementsByTagName("label");	
	var length = selects.length + inputs.length;
	
	var data = new Array();
	
	for(i=0; i < length; i++)
	{			
		if (inputs[i]) 
		{
			if (inputs[i].value == "")
			{
				targetDiv.innerHTML = inputs[i].name+" is missing";
				var error = 1;
				return;						
			}
			else
			{
				var error = 0;
				var field = inputs[i].name;
			        var value = inputs[i].value;
			        data[field] = value;				
			}
			
		}	
		
		if (selects[i])
		{
			if (selects[i].value == "")
			{
				targetDiv.innerHTML = selects[i].name+" is missing";
				var error = 1;
				return;
			}
			else
			{
				var error = 0;
				var field = selects[i].name;
				var value = selects[i].value;
                                data[field] = value;
			}	
			
		}
	}	
		if (error == 0)
		{
			targetDiv.innerHTML = "";
			saveForm(form, messageDiv, data);
		}				
	
}

I've managed to half do this by using a numerical value for the key but I really need to have the form field name as the key so that I can associate the form field with the data when I pass it to the php script.  Having said that when I use numeric keys on the second half is completed (the selects) becuause the inputs are all over written because the array key isnt incremented until the next iteration of the for loop.

I would really apprciate some guidance on this, Im kinda new to JavaScript!!

Cheers y'all

Bryant May

AnswerRe: Javascript - Dynamic arrays Pin
fly90416-Mar-09 8:30
fly90416-Mar-09 8:30 
GeneralRe: Javascript - Dynamic arrays Pin
Bryant May17-Mar-09 4:10
Bryant May17-Mar-09 4:10 
GeneralRe: Javascript - Dynamic arrays [modified] Pin
fly90417-Mar-09 5:56
fly90417-Mar-09 5:56 
GeneralRe: Javascript - Dynamic arrays Pin
fly90417-Mar-09 9:37
fly90417-Mar-09 9:37 
Question"ASP" Email sending problem.. [modified] Pin
D.Manivelan16-Mar-09 4:27
D.Manivelan16-Mar-09 4:27 
AnswerRe: "ASP" Email sending problem.. Pin
tech60316-Mar-09 17:46
tech60316-Mar-09 17:46 
GeneralRe: "ASP" Email sending problem.. Pin
D.Manivelan17-Mar-09 0:57
D.Manivelan17-Mar-09 0:57 
GeneralRe: "ASP" Email sending problem.. Pin
tech60317-Mar-09 3:18
tech60317-Mar-09 3:18 
GeneralRe: "ASP" Email sending problem.. Pin
D.Manivelan18-Mar-09 2:08
D.Manivelan18-Mar-09 2:08 
GeneralRe: "ASP" Email sending problem.. Pin
tech60318-Mar-09 4:17
tech60318-Mar-09 4:17 
GeneralRe: "ASP" Email sending problem.. Pin
D.Manivelan19-Mar-09 18:46
D.Manivelan19-Mar-09 18:46 
GeneralRe: "ASP" Email sending problem.. Pin
tech60320-Mar-09 4:43
tech60320-Mar-09 4:43 
GeneralRe: "ASP" Email sending problem.. Pin
D.Manivelan22-Mar-09 18:43
D.Manivelan22-Mar-09 18:43 
GeneralRe: "ASP" Email sending problem.. Pin
tech60324-Mar-09 3:32
tech60324-Mar-09 3:32 
QuestionAjax enabled page stops responding after kept idle for some time Pin
Member 56545116-Mar-09 2:08
Member 56545116-Mar-09 2:08 
Questionsending emails on localhost Pin
NetQuestions15-Mar-09 22:29
NetQuestions15-Mar-09 22:29 
AnswerRe: sending emails on localhost Pin
Marc Firth15-Mar-09 23:24
Marc Firth15-Mar-09 23:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.