d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Having Troubles In My Javascript Class
Add Reply New Topic New Poll
Member
Posts: 3,188
Joined: Jul 27 2014
Gold: Locked
Trader: Scammer
Sep 12 2014 01:36pm
Anyone able to help? Can pm you the script or something and have you check over it, not sure why it isn't working :/
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Sep 12 2014 02:00pm
Post your script here.
Member
Posts: 3,188
Joined: Jul 27 2014
Gold: Locked
Trader: Scammer
Sep 12 2014 02:19pm
Arrow is the part that's not working. When I add in the name/relationship and hit add guest, nothing happens.

Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CV Wedding Hall</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="wedding_hall.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
/* <![CDATA[ */
function addGuest(){
var guestInfo=document.newGuest.guestName.value + ", ";
guestinfo+=document.newGuest.relationship.value;
document.newGuest.guests.value=guestInfo;
}
/* ]]> */
</script>
</head>
<body>
<table border="0" width="780" cellpadding="0" cellspacing="0">
<tr>
<td>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="images/head1.jpg" width="246" height="395" alt="Visual formatting element" />
</td>
<td>
<img src="images/head2.jpg" width="193" height="395" alt="Visual formatting element" />
</td>
<td>
<div>
<img src="images/head3.jpg" width="226" height="193" alt="Visual formatting element" /></div>
<div>
<img src="images/head5.jpg" width="226" height="200" alt="Visual formatting element" /></div>
</td>
<td>
<img src="images/head4.jpg" width="115" height="397" alt="Visual formatting element" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="c7">
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td class="c4">
<div class="c3">
<h1>
<img src="images/h_guestbook.gif" alt="Visual formatting element" width="100" height="21" border="0" /></h1>

<form action="" method="post" name="newGuest">
<p>
Guest
<input type="text" name="guestName"
style="width: 240px" />&nbsp;
<br />
Relationship
<input type="text" name="relationship"
style="width: 210px" />
<input type="button" value="Add Guest" onclick= "addGuest()"/></p> <---------------------------------------------------
<p>
<textarea name="guests"></textarea>
</p>
</form>

</div>
<img src="images/slash.gif" style="margin-top: 200px" width="374" height="29" alt="Visual formatting element" />
</td>
<td>
<div>
<a href="index.html">
<img src="images/m2.gif" width="159" height="30" alt="Visual formatting element" /></a></div>
<div>
<a href="guestbook.html">
<img src="images/m5.gif" width="159" height="30" alt="Visual formatting element" /></a></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="c8" id="foot">
<p>
2010 &copy; CV Wedding Hall. All rights reserved.V Wedding Hall. All rights reserved.</p>
</td>
</tr>
</table>
</body>
</html>


This post was edited by nikesins on Sep 12 2014 02:23pm
Retired Moderator
Posts: 21,073
Joined: Apr 7 2008
Gold: 5,135.90
Trader: Trusted
Sep 12 2014 02:20pm
Use code tags so that we can see the indenting.
Member
Posts: 3,188
Joined: Jul 27 2014
Gold: Locked
Trader: Scammer
Sep 12 2014 02:22pm
Quote (Kagura @ Sep 12 2014 04:20pm)
Use code tags so that we can see the indenting.


Found it + fixed, thanks! Gotta go work out, be back in a bit, any help is greatly appreciated!

This post was edited by nikesins on Sep 12 2014 02:23pm
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Sep 12 2014 02:52pm
Your code is fine, minus a capital letter.

Code
<script type="text/javascript">
/* <![CDATA[ */
function addGuest(){
var guestInfo=document.newGuest.guestName.value + ", ";
guestInfo+=document.newGuest.relationship.value;
document.newGuest.guests.value=guestInfo;
}
/* ]]> */
</script>


You had guestInfo += document... as guestinfo +=.

A quick tip, if you're using Chrome go to View -> Developer -> Javascript Console. It will spit back any errors you're getting and help you pinpoint / debug it better.

This post was edited by Blind[zF] on Sep 12 2014 02:58pm
Member
Posts: 3,188
Joined: Jul 27 2014
Gold: Locked
Trader: Scammer
Sep 12 2014 04:17pm
Quote (Blind[zF&#93; @ Sep 12 2014 04:52pm)
Your code is fine, minus a capital letter.

Code
<script type="text/javascript">
/* <![CDATA[ */
function addGuest(){
  var guestInfo=document.newGuest.guestName.value + ", ";
  guestInfo+=document.newGuest.relationship.value;
  document.newGuest.guests.value=guestInfo;
}
/* ]]> */
</script>


You had guestInfo += document... as guestinfo +=.

A quick tip, if you're using Chrome go to View -> Developer -> Javascript Console. It will spit back any errors you're getting and help you pinpoint / debug it better.


Such a petty error, these get me all the time! Gah! Thanks man !!!
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll