Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Submitting forms

Options
  • 06-04-2005 11:25am
    #1
    Closed Accounts Posts: 4,655 ✭✭✭


    Does anyone know of any sites that show forms being submitted, even if the submit element is at the top of the page.

    For example hotmail's inbox or something similiar to the attachment I have included.

    Basically I have a form and depending on which link you click on the left (edit or delete) I need to be able to validate the checkboxes select

    i.e. Ensure that when someone clicks "edit" only one textbox is selected or allow for multiple selections when they press "delete" and also to ensure that atleast one checkbox is selected when clicking on either link

    anyone got any pointers


Comments

  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    OK, quite bored here, so did a similar page using client side JScript for the validation. The checkboxes all have the same name so they can be accessed through an array. Sorry if this is nothing like what you were asking...
    <html>
    	<head>
    		<title>test page</title>
    		<script type="text/JavaScript">
    			function doAction(sAction)
    			{
    				// amount of names on the page - retrieved by your serverside code
    				// zero based array, so subtract 1 from the amount
    				var nNameCount = 3;
    
    				// holder for the amount of checkboxes that are checked
    				var nCheckedAmount = 0;
    
    				// loop through the amount of checkboxes
    				for (i = 0; i <= nNameCount; i++)
    				{
    					// if it is checked then increase the variable by one
    					if (document.frmEoin.chkName[i].checked)
    					{
    						nCheckedAmount ++;
    					}
    				}
    
    				// return a message if no options were selected
    				if (nCheckedAmount == 0)
    				{
    					alert("no options were selected");
    				}
    
    
    				// check the action of the form:
    				// if it is delete, then more than one option must be selected
    				if (sAction == "delete")
    				{
    					if (nCheckedAmount > 0)
    					{
    						alert("names can be deleted");
    					}
    				}
    				else if (sAction == "edit")
    				{
    					if (nCheckedAmount == 1)
    					{
    						alert("name can be edited")
    					}
    					else if (nCheckedAmount > 1)
    					{
    						alert("you selected more than one option");
    					}
    				}
    			}
    		</script>
    	</head>
    	<body>
    		<form name="frmEoin" action="thisPage.asp" method="post">
    			<a href="JavaScript: doAction('edit')">edit</a>
    			| <a href="JavaScript: doAction('delete')">delete</a>
    			<table>
    				<tr>
    					<td>Name 1</td>
    					<td><input type="checkbox" value="Name1" name="chkName"></td>
    				</tr>
    				<tr>
    					<td>Name 2</td>
    					<td><input type="checkbox" value="Name2" name="chkName"></td>
    				</tr>
    				<tr>
    					<td>Name 3</td>
    					<td><input type="checkbox" value="Name3" name="chkName"></td>
    				</tr>
    				<tr>
    					<td>Name 4</td>
    					<td><input type="checkbox" value="Name4" name="chkName"></td>
    				</tr>
    			</table>
    		</form>
    	</body>
    </html>
    


Advertisement