Okay, im having a little difficulty trying to code a #FollowFriday tweet generator for my website. My code works perfectly creating the tweet, but I want to make it so that when I hit the Submit button, it uses the text from the textarea to encode a URL and append it to the end of http://twitter.com/home?status=. For example if the text in the textbox says "#FollowFriday #FF @FATBOISLIMM" then it generates and opens this URL (http://twitter.com/home?status=%23Fo...%40FATBOISLIMM) in their browser window. Here is the code I have:
Code:
<script type = "text/javascript">
//www.SlapTV.net
//www.LILPOTSPRODUCTIONS.com
function text(t){
a = document.getElementById('statusPreview');
a.value += t;
}
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
cntfield.value = maxlimit - field.value.length;
}
function showtext() {
var output = "";
if (document.getElementById("chk1").checked) {
output = output + "#FollowFriday ";
}
if (document.getElementById("chk2").checked) {
output = output + "#FF ";
}
if (document.getElementById("chk3").checked) {
output = output + "@_SlapTV ";
}
if (document.getElementById("chk4").checked) {
output = output + "@FATBOISLIMM ";
}
document.getElementById("statusPreview").value = output;
}
</script>
<center>
<form name="status" action="http://twitter.com/statuses/update.xml" method="POST" enctype="application/x-www-form-urlencoded">
<textarea name="statusPreview" id="statusPreview" wrap="physical" cols="55" rows="3"
onKeyDown="textCounter(document.status.statusPreview,document.status.remLen2,140)"
onKeyUp="textCounter(document.status.statusPreview,document.status.remLen2,140)"></textarea>
<br>
<input readonly type="text" name="remLen2" size="3" maxlength="3" value="140">
characters left
<input type="Submit" class="Submit" value="TGIFF">
<br /><br>
<input type = "checkbox" id = "chk1" onclick = "showtext()">#FollowFriday
<input type = "checkbox" id = "chk2" onclick = "showtext()">#FF <br /><br />
<input type = "checkbox" id = "chk3" onclick = "showtext()">SlapTV
<input type = "checkbox" id = "chk4" onclick = "showtext()">T
as you can see it generates the text just fine, but I dont know how to make it encode and open the URL. Please help!!
exactly but when you encode the URL you shouldn't need to insert a password as long as your already signed into twitter because this method of updating your status is HTTP based. when you click Submit from my program i want it to encode whats in the textbox into a URL, attach that to the end of 'http://twitter.com/home?status=' and open that link. because when you open that link it will bring you to your twitter homepage and whatever have after home?status=...... will be in your status box waiting for you to click Update
no, you only need a Twitter account to test it. all i need help with is encoding the text thats in the text box into URL format when the submit button is hit, and append that to the end of this URL: http://twitter.com/home?status=
as you see, the link created a status message for you (everything after home?status= is inserted into your status update box)
this is what i want my code to do:
-user checks any combination of boxes [done]
-corresponding text appears in textarea [done]
-when user clicks Submit button (TGIFF), it encodes the text in the textarea into a format like this:
okay okay we're making progress. that escape function is going to come in handy, but is there a way we can make the escape not encode anything until AFTER the Submit button is clicked? because i dont want the user to have to see what the encoded version of the text looks like ya know? here is what its going to look like in case you need to see it in action: www.slaptv.net/followfriday.html
oh man thats it! thanks a lot. yea this was my first program, and i went to google as much as i could until i got stuck..thats when i came to you. but i appreciate all the help man!
Bookmarks