Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with my Java Script

    My code shown here is working but I need help adding 2 more groups to receive the message w/multiple select for each grouping . Right now I can select on person from Group1 and send a static message or a free text message to a usmobility pager. So what I would like to to be able to select multiple people from each group and send them a message. Kind of like a group/individual paging system. Thanks for all the help.



    Code:
    <!doctype>
    
    <html lang="en">
    	<head>
    		<meta charset="utf8">
    		<title>Test form</title>		
    		
    		<style>
    			body
    			{
    				font-family: arial;
    				line-height: 2;
    			}
    			select
    			{
    				display: block;
    				min-width: 150px;
    			}
    			
    			#free_text
    			{
    				width: 500px;
    			}
    			
    			#preview
    			{
    				background: #ccc;
    				border: 1px solid #000;
    				padding: 10px;
    				margin: 10px 0;
    				font-size: 1.5em;
    			}
    			
    			#submit
    			{
    				margin: 20px 0 0;
    			}
    			
    		</style>
    	</head>
    
    	<body>
    		<form id="f" method="post" action="http://www.usamobility.net/cgi-bin/wwwpage.exe">
    			<fieldset>
    				<legend>Contact/Location</legend>
    				
    				<label for="contact">Group1:</label>
    				<select id="contact">
    					<option value=""></option>
    					<option value="2065401040">Person1</option>
    					<option value="2065401040">Person2</option>
    					<option value="2065401040">Person3</option>
    					
    				</select>
    				
    				<label for="location">Location:</label>
    				<select id="location">
    					<option value="Room 1">Room1</option>
    					<option value="Room 2">Room2</option>
    					<option value="Room 3">Room3</option>
    									
    				</select>
    				
    
    				<div>
    					<input type="radio" name="msg_type" id="msg_type_static" value="static" checked="checked" />
    					<label for="msg_type_static">Static message: </label><span id="static_msg"></span>
    				</div>
    				
    				<div>
    					<input type="radio" name="msg_type" id="msg_type_free" value="free" />
    					<label for="msg_type_free">Free text: </label>
    					<input id="free_text" type="text" />
    				</div>
    				
    				
    				<div id="preview">The message: &quot;<span id="msg_preview"></span>&quot; will be send to <span id="receiver"></span></div>
    				
    				<input type="submit" id = "submit" value = "Send Message" />
    				
    				<input type="hidden" id="pin" name="PIN" />
    				<input type="hidden" id="name" name="NAME" />
    				<input type="hidden" id="mssg" name="MSSG" />
    				<input type="hidden" name="Q1" value="1" />
    				
    			</fieldset>
    		</form>
    		
    		<script>
    			window.onload = function()
    			{
    				var f = document.getElementById('f');
    				var p = document.getElementById('pin');
    				var n = document.getElementById('name');
    				var m = document.getElementById('mssg');			
    				var c = document.getElementById('contact');
    				var l = document.getElementById('location');
    				var free_text = document.getElementById('free_text');
    				var msg_preview = document.getElementById('msg_preview');
    				var receiver = document.getElementById('receiver');
    				
    				l.onchange = setStaticMessage;
    				c.onchange = setStaticMessage;
    				free_text.onkeyup = setStaticMessage;
    				
    				var len = f.msg_type.length;
    				while (len--)
    				{
    					f.msg_type[len].onchange = setStaticMessage;
    				}
    				
    				setStaticMessage();
    				
    				function getName()
    				{
    					var ops = c.options;
    					var i = ops.length;
    					while (i--)
    					{
    						if (ops[i].selected)
    						{
    							return ops[i].text;
    						}
    					}
    				}
    				
    				function getMessageType()
    				{
    					var i = f.msg_type.length;
    					while (i--)
    					{
    						if (f.msg_type[i].checked)
    						{
    							return f.msg_type[i].value;
    						}
    					}
    				}
    				
    				function setStaticMessage()
    				{
    					var msg;
    					var msgType = getMessageType();
    					if (msgType === 'static')
    					{
    						msg = l.value + ' is ready for turnover';
    						setText(document.getElementById('static_msg'), msg);
    					}
    					else
    					{
    						msg = free_text.value + '|' + l.value + '|' ;
    					}
    					
    					
    					
    					p.value = c.value;
    					n.value = getName();
    					m.value = msg;
    					
    					setText(msg_preview, m.value);
    					setText(receiver, n.value);
    				}
    				
    				function setText(node, val)
    				{
    					if (node.firstChild)
    					{
    						node.firstChild.nodeValue = val;
    					}
    					else
    					{
    						node.appendChild(document.createTextNode(val));
    					}
    				}
    			};
    			
    		</script>
    	</body>
    </html>
    Last edited by augold3; 06-05-2012 at 09:55 PM.

  • #2
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I checked the usmobility website and it does not accept mutilple pager entries. So is there a way to run the script for each person selected? So if two people are selected the script pages the first one and then does it again for the next person. ( Considering the question from the original post on how to add another user group is answered.) Again any help is apprieciated.

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any Ideas?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •