Page 6 of 6

Re: Sending SMS

Posted: Wed Mar 17, 2010 10:44 pm
by closey
Luxyboy wrote:Using the above mentioned variables this new one gives you a drop down box menu.
I've taken it one step further and added a bunch of javascript niceties, as well as use of an iframe for the submit, so you don't have to navigate away from the page. You have to paste this into something like "sendsms.htm" and send it to your phone. It's optimised for a N78 screen, but will most likely fit on others too. I sent this to my phone as a bluetooth message and then copied it into a different folder for easy access. This way it's still within the 'messaging' part of the phone... most convenient :)

Code: Select all

<html>
<head><title>SMS Over IP</title></head>
<body onload="UpdateCount();" style="vertical-align:top;">
<script>
function UpdateCount(setFocus)
{
	var chars = document.getElementById('message').value.length;
	var chopped = false;
	var messages = 1;
	var messageSize = 160;
	var s = 's';
	if (chars > 608)
	{
		document.getElementById('message').value = document.getElementById('message').value.substring(0, 608);
		chars = document.getElementById('message').value.length;
		chopped = true;
		s += '. Message was too long.';
	}
	var charsLeft = chars;
	if (chars > 456)
	{
		messages = 4;
		messageSize = 608;
	}
	else if (chars > 304)
	{
		messages = 3;
		messageSize = 456;
	}
	else if (chars > 160)
	{
		messages = 2;
		messageSize = 304;
	}
	else
	{
		s = '';
	}
	document.getElementById('spanCount').innerHTML = chars + '/' + messageSize + ' (' + messages + ' message' + s + ')';
	if (setFocus)
	{
		document.getElementById('submit').focus();
	}
	document.getElementById('hideMe').style.display='';
}

function ClearValues(doAll)
{
	document.getElementById('message').value = '';
	document.getElementById('myFrame').src = 'about:blank';
	UpdateCount(false);
	if (doAll)
	{
		document.getElementById('mobilenumber').value = '';
		document.getElementById('original_mobile_number').value = '';
		document.getElementById('mobilenumber').focus();
	}
	else
	{
		document.getElementById('message').focus();
	}
}
</script>
<form action="https://www.exetel.com.au/sendsms/api_sms.php" method="post" target="myFrame" onsubmit="document.getElementById('hideMe').style.display='none';">
<input type="hidden" name="username" value="YOUR_USERNAME" />
<input type="hidden" name="password" value="YOUR_PASSWORD" />
<input type="hidden" name="messagetype" value="Text" />
<input type="hidden" name="sender" size="12" maxlength="12" value="YOUR_MOBILE"/>
<pre/>
To: <select id="mobilenumber" name="mobilenumber" onchange="this.form.original_mobile_number.value=this.options[this.selectedIndex].value;document.getElementById('message').focus();">
<option value=""></option>
<option value="04xxxxxxxx"> Person 1</option>
<option value="04xxxxxxxx"> Person 2</option>
<option value="04xxxxxxxx"> Person 3</option>
<option value="04xxxxxxxx"> Person 4</option>
</select> <input type="text" id="original_mobile_number"  name="original_mobile_number" size="12" maxlength="12" value="" />
Message:
<textarea id="message" name="message" rows="6" cols="54" onkeyup="UpdateCount(false);" onchange="UpdateCount(true);" ></textarea>
<span id="spanCount">0 characters entered</span>
<input id="submit" type="submit" value="Submit" style="width:100%;max-width:200px;" />
</pre/>
</form>
<a href="javascript:ClearValues();">Clear Text</a>
<a href="javascript:ClearValues(true);">Clear All</a>
<p id="hideMe"> You will see "OK" at the end, if SMS was sent. </p/>
<iframe id="myFrame" name="myFrame" src="about:blank" style="width:100%;padding:0 0 0 0;border-style:none;border:0 0 0 0:padding:0 0 0 0"/>
</body>
</html>

Re: Sending SMS

Posted: Thu Mar 18, 2010 10:33 am
by davesa
I Like the idea, but if I leave the option list on the blank value and type a 'send to' number it submits the url with "mobilenumber=" ie. a blank number, so doesn't work in this case.

Re: Sending SMS

Posted: Wed May 26, 2010 11:02 pm
by wasabi
closey wrote:
Luxyboy wrote:Using the above mentioned variables this new one gives you a drop down box menu.
I've taken it one step further and added a bunch of javascript niceties, as well as use of an iframe for the submit, so you don't have to navigate away from the page. You have to paste this into something like "sendsms.htm" and send it to your phone. It's optimised for a N78 screen, but will most likely fit on others too. I sent this to my phone as a bluetooth message and then copied it into a different folder for easy access. This way it's still within the 'messaging' part of the phone... most convenient :)

Code: Select all

<html>
<head><title>SMS Over IP</title></head>
<body onload="UpdateCount();" style="vertical-align:top;">
<script>
function UpdateCount(setFocus)
{
	var chars = document.getElementById('message').value.length;
	var chopped = false;
	var messages = 1;
	var messageSize = 160;
	var s = 's';
	if (chars > 608)
	{
		document.getElementById('message').value = document.getElementById('message').value.substring(0, 608);
		chars = document.getElementById('message').value.length;
		chopped = true;
		s += '. Message was too long.';
	}
	var charsLeft = chars;
	if (chars > 456)
	{
		messages = 4;
		messageSize = 608;
	}
	else if (chars > 304)
	{
		messages = 3;
		messageSize = 456;
	}
	else if (chars > 160)
	{
		messages = 2;
		messageSize = 304;
	}
	else
	{
		s = '';
	}
	document.getElementById('spanCount').innerHTML = chars + '/' + messageSize + ' (' + messages + ' message' + s + ')';
	if (setFocus)
	{
		document.getElementById('submit').focus();
	}
	document.getElementById('hideMe').style.display='';
}

function ClearValues(doAll)
{
	document.getElementById('message').value = '';
	document.getElementById('myFrame').src = 'about:blank';
	UpdateCount(false);
	if (doAll)
	{
		document.getElementById('mobilenumber').value = '';
		document.getElementById('original_mobile_number').value = '';
		document.getElementById('mobilenumber').focus();
	}
	else
	{
		document.getElementById('message').focus();
	}
}
</script>
<form action="https://www.exetel.com.au/sendsms/api_sms.php" method="post" target="myFrame" onsubmit="document.getElementById('hideMe').style.display='none';">
<input type="hidden" name="username" value="YOUR_USERNAME" />
<input type="hidden" name="password" value="YOUR_PASSWORD" />
<input type="hidden" name="messagetype" value="Text" />
<input type="hidden" name="sender" size="12" maxlength="12" value="YOUR_MOBILE"/>
<pre/>
To: <select id="mobilenumber" name="mobilenumber" onchange="this.form.original_mobile_number.value=this.options[this.selectedIndex].value;document.getElementById('message').focus();">
<option value=""></option>
<option value="04xxxxxxxx"> Person 1</option>
<option value="04xxxxxxxx"> Person 2</option>
<option value="04xxxxxxxx"> Person 3</option>
<option value="04xxxxxxxx"> Person 4</option>
</select> <input type="text" id="original_mobile_number"  name="original_mobile_number" size="12" maxlength="12" value="" />
Message:
<textarea id="message" name="message" rows="6" cols="54" onkeyup="UpdateCount(false);" onchange="UpdateCount(true);" ></textarea>
<span id="spanCount">0 characters entered</span>
<input id="submit" type="submit" value="Submit" style="width:100%;max-width:200px;" />
</pre/>
</form>
<a href="javascript:ClearValues();">Clear Text</a>
<a href="javascript:ClearValues(true);">Clear All</a>
<p id="hideMe"> You will see "OK" at the end, if SMS was sent. </p/>
<iframe id="myFrame" name="myFrame" src="about:blank" style="width:100%;padding:0 0 0 0;border-style:none;border:0 0 0 0:padding:0 0 0 0"/>
</body>
</html>

does this code work and where do i enter my username and pw ?