Author Topic: JavaScript Issue  (Read 4691 times)

Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
JavaScript Issue
« on: December 23, 2006, 12:11:33 PM »
I am using this JS to insert a value into a form text box, it works great but when someone clicks another link, it changes the form text box to the newly clicked value. I would like it to append to the existing value.

Eg; it inserts "one" and when i click on two, it changes "one" to "two", i would like it to show "one two"

Code: [Select]
<script language='javascript' type="text/javascript">
<!-- Hide script from older browsers
        function cc(val) {
           document.form1.cc.value = val
        }
// End hiding script from older browsers -->
</script>

Offline Reverend Greed

  • PLA Guru
  • *****
  • Posts: 224
  • 1337 13V3L: +42/-7
Re: JavaScript Issue
« Reply #1 on: December 23, 2006, 02:06:58 PM »
I am using this JS to insert a value into a form text box, it works great but when someone clicks another link, it changes the form text box to the newly clicked value. I would like it to append to the existing value.

Eg; it inserts "one" and when i click on two, it changes "one" to "two", i would like it to show "one two"

Code: [Select]
<script language='javascript' type="text/javascript">
<!-- Hide script from older browsers
        function cc(val) {
           document.form1.cc.value = val
        }
// End hiding script from older browsers -->
</script>


Change this line:

Code: [Select]
document.form1.cc.value = val
To this:

Code: [Select]
document.form1.cc.value += val
Reboot America

Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
Re: JavaScript Issue
« Reply #2 on: December 23, 2006, 02:34:11 PM »
That worked.  Thanks!!!!!


Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
Re: JavaScript Issue
« Reply #3 on: December 23, 2006, 02:41:06 PM »
Can you include JS, html, and php into one file?  I want my site to have a login that keeps the user logged in the entire time.  Where would I start?

I use the forum used here but I just converted the database from invision to smf.

Offline Reverend Greed

  • PLA Guru
  • *****
  • Posts: 224
  • 1337 13V3L: +42/-7
Re: JavaScript Issue
« Reply #4 on: December 23, 2006, 02:55:56 PM »
Can you include JS, html, and php into one file?  I want my site to have a login that keeps the user logged in the entire time.  Where would I start?

I use the forum used here but I just converted the database from invision to smf.

1.  Yes.

2.  You'll need to use SSI......and what's nice is that the commands are already in place.  For example:

ssi_welcome();
ssi_login();

This will automatically create the login and welcome portion.  You just need to place it in your php file (index.php or whatever)
Reboot America

Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
Re: JavaScript Issue
« Reply #5 on: December 23, 2006, 03:15:55 PM »
Ok this is what I did.

Code: [Select]
<?php
include './forum/SSI.php';

ssi_welcome();
ssi_login();
?>


But I want the login to be nice looking with a blue border, red lettering, and whatnot.  How do i do this?

Offline Reverend Greed

  • PLA Guru
  • *****
  • Posts: 224
  • 1337 13V3L: +42/-7
Re: JavaScript Issue
« Reply #6 on: December 23, 2006, 03:31:05 PM »
Ok this is what I did.

Code: [Select]
<?php
include './forum/SSI.php';

ssi_welcome();
ssi_login();
?>


But I want the login to be nice looking with a blue border, red lettering, and whatnot.  How do i do this?

Use CSS.  Then reference the style sheet in the <head> portion within your php code.
Reboot America

Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
Re: JavaScript Issue
« Reply #7 on: December 23, 2006, 04:06:05 PM »
I'll be honest, I don't know how to do that.  Will you show me?

Offline Reverend Greed

  • PLA Guru
  • *****
  • Posts: 224
  • 1337 13V3L: +42/-7
Re: JavaScript Issue
« Reply #8 on: December 23, 2006, 06:23:29 PM »
I'll be honest, I don't know how to do that.  Will you show me?

Okay, do this:

PHP code and name the file whatever suits you ending with *.php.

Code: [Select]
<?php
include './forum/SSI.php';
echo 
'<head><link rel="stylesheet" type="text/css" href="login.css" /></head><body>
<fieldset>
<legend>Go directly to the <a href="/forum">forum</a>.</legend>'
;
ssi_welcome();
ssi_login();
echo 
'</fieldset> </body>';
?>

And here's the CSS code that should be named "login.css" in order for your PHP file to pick it up. 

Code: [Select]
input[type="submit"]{
margin-left: 5em;
clear: both;
color: #000;
background: #fb0;
border: 2px #9cf outset
}

fieldset
{
border: #26a solid 1px;
width: 20em
}

legend
{
background: #fb0;
border: #26a solid 1px;
padding: 1px 10px
}

label
{
width: 4em !important;
float: left !important;
text-align: right !important;
margin: 0 1em 10px 0 !important;
clear: both !important;
}

input[id="user"], input[id="passwrd"]
{
float: left;
margin-bottom: 10px;
color: #26a;
background: #feb;
border: #26a solid 1px
}

The way it's written - the CSS file needs to be in the same directory as the PHP file.  I currently set the hyper reference towards whatever directory you place it in. 

Hope this helps.
Reboot America

Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
Re: JavaScript Issue
« Reply #9 on: December 23, 2006, 10:21:26 PM »
Dude!  This is exactly want I wanted and it works beautifully, you're a ninja.  Can I paypal you some cash for your time?

Offline Reverend Greed

  • PLA Guru
  • *****
  • Posts: 224
  • 1337 13V3L: +42/-7
Re: JavaScript Issue
« Reply #10 on: December 23, 2006, 10:41:13 PM »
Dude!  This is exactly want I wanted and it works beautifully, you're a ninja.  Can I paypal you some cash for your time?

No.  Go donate to your local battered women's shelter.
Reboot America

Offline BrianOlsen

  • Junior Phone Loser
  • **
  • Posts: 23
  • 1337 13V3L: +0/-0
Re: JavaScript Issue
« Reply #11 on: December 26, 2006, 02:26:40 PM »
Ok I did that.  I used paypal to donate $20.00 to an online organization.