View Full Version : I need a JS program
Sikawtic
10-21-2005, 10:25 AM
I need a JS program... It needs to have 5 text boxes (things that you type in):
1) color code (such as d4d4d4)
2) url (such as http://www.url.com (http://www.url.com/))
3) title (such as OMG)
4) date/time (such as Wed Jul 20, 2005 8:48 pm)
5) author (such as Sikawtic)
after you type them all in it would need to print a line such as this (replace html tags with vB tags):
<color=d4d4d4><url = http://www.url.com>OMG</url></color> - <i>Wed Jul 20, 2005 8:48 pm</i> (Sikawtic)
So when I would post it in a forum it would show up as:
OMG (http://www.url.com/) - Wed Jul 20, 2005 8:48 pm (Sikawtic)
Can anyone help me?
Thanks in advance,
~Sikawtic
UPDATE:
Instead of having a color text input box, could you make it a menu? It would need to have options like "dwarf" that when selected would print the color code "6F4717" in its appropriate place... I need you to write it so that I can continue putting in selections w/ color code output. (i only have 10 right now, but I'll be adding more later... I can post the list of ones I have right now if it's requested)
So.. I'm aiming for something like:
[color selection menu] [text input box for "url"] [text input box for "title"] [text input box for "date/time"] [text input box for "author"] [submit button]
And now, I'm going to ask for something even more (if it's possible, this step is not necassary). Could you have a button below the deal above that has a "add link" that makes another identical thing appear? so it would be:
[menu deal][submit]
[button for +1 menu]
[output box]
when you press button it would be:
[menu deal]
[menu deal][submit]
[button]
[output box]
When you press [submit] it would print the selected stuff above in the output box (each menu would go onto a different line, make it so it's easy to tell them apart). The menu deal would then reset to the default 1 selection and would have the output in the bottom... if that makes sense.
Sikawtic
10-21-2005, 12:51 PM
Can I get a lil help pweeze?
GrassDragon
10-21-2005, 1:09 PM
Google "html javascript form" or something of the like. It shouldn't be especially hard for you to learn how to do it.
Sikawtic
10-21-2005, 2:02 PM
I'm currently trying to do it in php. :)
<?php
$name = "paul";
?>
<?php print( "$name" ); ?>
^why can't i get a simple program like that to work???
GrassDragon
10-21-2005, 2:21 PM
I don't know about print(); I always use echo.
You still use a form with PHP though. Just have it's action be the same page that has the form, and at the top make it check for posted variables. If it has some you've already filled that out and it can display the result, if not it'll give you the form for inputting.
EDIT: Oh and you shouldn't need quotes if it's a variable name.
I can probably do it for you. Give me thirty minutes.
EDIT: It will take me more time, as I won't be home for the next three hours :)
UED77
Markpyro
10-21-2005, 3:36 PM
I dont quite understand what you're doing this for... elaborate?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" title="" href="" type="text/css" media="screen" />
<?xml-stylesheet href="" type="text/css" media="screen" ?>
<title></title>
</head>
<body>
<form name="form">
<p>
<select name="color">
<option value="1">Color 1</option>
<option value="2">Color 2</option>
<option value="3">Color 3</option>
<option value="4">Color 4</option>
<option value="5">Color 5</option>
<option value="6">Color 6</option>
<option value="7">Color 7</option>
</select>
<input type="text" name="url" />
<input type="text" name="title" />
<input type="text" name="date" />
<input type="text" name="user" />
<input type="button" value="Send" onclick="process()" /><input type="reset" />
</p>
<script type="text/javascript">
function process() {
var text = "[color=\"";
if (document.form.color.selectedIndex==0) {
text = text+"#d4d4d4";}
else if (document.form.color.selectedIndex==1) {
text = text+"#ffffff";}
else {text = text+"#000000";}
text = text+"\"]";
if (!document.form.url.value=="") {
text = text+"[url=\""+document.form.url.value+"\""+"]";}
text = text+document.form.title.value;
if (!document.form.url.value=="") {
text = text+"[\/url]";}
text = text+"[\/color]"+" — "+"[i]"+document.form.date.value+"[\/i]"+" ("+document.form.user.value+")";
document.write(text);
}
</script>
</form>
</body>
</html>
You will have to change the colors around, and add labels, optionally. Or you can just memorize which one does what =]
Enjoy,
UED77
Sikawtic
10-23-2005, 4:48 PM
Thanks UED77, this will spead up my productivity a lot.
@MP: I'm using it to help produce vB code for an archive thread at http://www.cobracards.com. I started it awhile ago, but quit because it was getting to tedious. I'm hoping UED's program will make it go quicker ^_^
Sikawtic
10-23-2005, 6:32 PM
UED, I'm having problems editting a certain thing... how can i make it so it will have 10 rows, and only one submit on the bottom? It would need to process all the things and print the code in 10 rows... I got it to where I thought it should be, but when I push "submit" it doesn't work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" title="" href="" type="text/css" media="screen" />
<?xml-stylesheet href="" type="text/css" media="screen" ?>
<title></title>
</head>
<body>
<form name="form">
<p>
<select name="color">
<option value="1">Dwarf</option>
<option value="2">Elf</option>
<option value="3">Gandalf</option>
<option value="4">Gondor</option>
<option value="5">Hobbit</option>
<option value="6">Rohan</option>
<option value="7">Smeagol</option>
<option value="8">Other</option>
</select>
<input type="text" name="url" value="URL" />
<input type="text" name="title" value = "Title"/>
<input type="text" name="date" value = "Date/Time" />
<input type="text" name="user" value = "Username" />
</p>
<p>
<select name="color2">
<option value="1">Dwarf</option>
<option value="2">Elf</option>
<option value="3">Gandalf</option>
<option value="4">Gondor</option>
<option value="5">Hobbit</option>
<option value="6">Rohan</option>
<option value="7">Smeagol</option>
<option value="8">Other</option>
</select>
<input type="text" name="url2" value="URL" />
<input type="text" name="title2" value = "Title"/>
<input type="text" name="date2" value = "Date/Time" />
<input type="text" name="user2" value = "Username" />
<input type="button" value="Send" onclick="process()" /><input type="reset" />
</p>
<script type="text/javascript">
function process() {
var text = "[color=\"";
if (document.form.color.selectedIndex==0) {
text = text+"#6F4717";}
else if (document.form.color.selectedIndex==1) {
text = text+"#00AAF1";}
else if (document.form.color.selectedIndex==2) {
text = text+"#FFCC00";}
else if (document.form.color.selectedIndex==3) {
text = text+"#AAAAAA";}
else if (document.form.color.selectedIndex==4) {
text = text+"#2CBD00";}
else if (document.form.color.selectedIndex==5) {
text = text+"#AA0038";}
else if (document.form.color.selectedIndex==6) {
text = text+"#FF67C8";}
else {text = text+"#000000";}
text = text+"\"]";
if (!document.form.url.value=="") {
text = text+"[url=\""+document.form.url.value+"\""+"]";}
text = text+document.form.title.value;
if (!document.form.url.value=="") {
text = text+"[\/url]";}
text = text+"[\/color]"+" — "+"[i]"+document.form.date.value+"[\/i]"+" ("+document.form.user.value+")";
var text = text+<br>+"[color=\"";}
if (document.form.color2.selectedIndex==0) {
text = text+"#6F4717";}
else if (document.form.color2.selectedIndex==1) {
text = text+"#00AAF1";}
else if (document.form.color2.selectedIndex==2) {
text = text+"#FFCC00";}
else if (document.form.color2.selectedIndex==3) {
text = text+"#AAAAAA";}
else if (document.form.color2.selectedIndex==4) {
text = text+"#2CBD00";}
else if (document.form.color2.selectedIndex==5) {
text = text+"#AA0038";}
else if (document.form.color2.selectedIndex==6) {
text = text+"#FF67C8";}
else {text = text+"#000000";}
text = text+"\"]";
if (!document.form.url2.value=="") {
text = text+"[url=\""+document.form.url2.value+"\""+"]";}
text = text+document.form.title2.value;
if (!document.form.url2.value=="") {
text = text+"[\/url]";}
text = text+"[\/color]"+" — "+"[i]"+document.form.date2.value+"[\/i]"+" ("+document.form.user2.value+")";
document.write(text);
}
</script>
</form>
</body>
</html>
I made you 10 fields, and the submit button works. Regarding the code you posted above, you prematurely closed the function process(), and that's why it didn't work.
The URL is http://uedworld.webhop.net/misc/form.html, but please download it yourself, as it's likely I will remove it in a couple of days.
I love Javascript, by the way. I love how you can have variable object identifiers, which make the script portion of this form pretty short. I believe Javascript is often not used to its full potential, and instead abused for popups and other trivial functions.
Enjoy, and Happy Birthday!
UED77
Sikawtic
10-23-2005, 7:44 PM
Thank you much UED!!!
I'm planning on learning JS, even moreso now ^_^
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.