开发者

How do I combine these examples?

First of all, I would like to apologize for posting this again. I am new to this forum. Also, I cannot ad comments on my first post of this question, or send private messages to users who commented, therefore I can't properly communicate with anybody who tries to help. What is the proper way for me to communicate with people who may comment on or answer this post? Again, I'm sorry to be repeating this question. With that out of the way, I move on.


I am just now experimenting with Javascript, so my knowledge of it is small. I found a website that offers a guestbook tool ( http://www.bfnsoftware.com/index.php?eid=2013 ), and another that offers a star rating tool( addratings.com/ ). I would like to know what parts of the scripts to change and what to change them to in order for the result to be a star rating tool under each new guestbook post. By the way, I had to resort to scripts not hosted at my site because of file type restrictions at my web host.

The guestbook code is in two parts. The first is the input form. This is it in it's basic form:

<form action = "http://www.bfnsoftware.com/cgi-bin/home/Members/Guestbook/Guestbook.cgi?SiteID=30185&Book=3128" method = "POST">
<input type = "hidden" name = "action" value = "sign">
:: Guestbook ::
Name:
<input type = "text" name = "guestName" size = 30 maxlength = 60>
Email Address:
<input type = "text" name = "guestEmail" size = 30 maxlength = 100>
Website:
<input type = "text" name = "guestWebsite" size = 30 maxlength = 150>
Vote:
<select name = "guestVote" style = "width:203px;">
<option value = "0"> 0 - Worst
<option value = "1"> 1
<option value = "2"> 2
<option value = "3"> 3
<option value = "4"> 4
<option value = "5" SELECTED> 5 - Average
<option value = "6"> 6
<option value = "7"> 7
<option value = "8"> 8
<option value = "9"> 9
<option value = "10"> 10 - Best
</select>
:: Message ::
<textarea cols = 45 rows = 6 name = "guestMessage"></textarea>
<input type = "submit" value = "Submit">
</form>

I am not using the "guestWebsite", "guestEmail" or "guestVote" fields of the form on my site. I was able to choose to let users enter html in the "guestMessage" textarea.

This is part two of the guestbook code. I put it on the page that I would like the posts to parse on.

<script language = "JavaScript" src = "http://www.bfnsoftware.com/cgi-bin/home/Members/Guestbook/Guestbook.cgi?SiteID=30185&Book=3128&action=js">
</script>
<script language = "JavaScript">
 document.write("<font size = 3><b>" + Title + "</b></font><br>");
 document.write("<hr align = left color = #4F4F4F width = 400><p>");
 for (nextE = 0; nextE < FilledEntries; nextE++) {
  document.write('<table border = 0 cellpadding = 1 cellspacing = 0 width = 502 bgcolor = #000000><tr><td width = 502>');
  document.write('<table border = 0 cellpadding = 0 cellspacing = 0 width = 500 bgcolor = #DFDFDF>');
  document.write('<tr><td width = 10></td><td width = 100> Name:</td><td width = 390>' + GuestName[nextE] + '</td></tr>');
  document.write('<tr><td width = 10></td><td width = 100> E-mail: </td><td width = 390>' + GuestEmail[nextE] + '</td></tr>');
  document.write('<tr><td width = 10></td><td width = 100> Website:</td><td width = 390><a href = ' + GuestWebsite[nextE] + '>' + GuestWebsite[nextE] + '</a></td></tr>');
  document.write('<tr><td width = 10></td><td width = 100> Vote:</td><td width = 390>' + GuestVote[nextE] + '</td></tr>');
  document.write('<tr><td width = 10></td><td width = 100> Date:</td><td width = 390>' + GuestDate[nextE] + '</td></tr>');
  document.write('</table></td></tr><tr><td>');
  document.write('<table border = 0 cellpadding = 0 cellspacing = 0 width = 500 bgcolor = #DFDFDF>');
  document.write('<tr><td width = 10></td><td width = 100 valign = top>Message:</td><td width = 390>' + GuestMessage[nextE] + '</td></tr></table>');
  document.write('</td></tr></table><p>');
 }
</script>
<noscript>
<a href = "http://www.bfnsoftware.com/cgi-bin/home/Members/Guestbook/Guestbook.cgi?SiteID=30185&Book=3128&action=view">View Guestbook</a>
</noscript>

I have modified it like this:

<script language = "JavaScript" src = "http://www.bfnsoftware.com/cgi-bin/home/Members/Guestbook/Guestbook.cgi?SiteID=30185&Book=3128&action=js">
</script>
<script language = "JavaScript">

     document.write("<b>" + Title + "</b><br />");
     for (nextE = 0; nextE < FilledEntries; nextE++) {
         document.write('<div class="entry">Username:   ' + GuestName[nextE] + '<br />');
       开发者_运维知识库  document.write('Submission Date:   ' + GuestDate[nextE] + '<br />');
         document.write('Line Submission:   ' + GuestMessage[nextE] + '<br /><br />');
         document.write('</div>');
     }
</script>

Next is the star rating script. Here is what I'm using:

<script type='text/javascript'>
 aR_BgColor="";
 aR_FgColor="";
 aR_url=location.href + "";
 aR_title=document.title + "";
 aR_StarType ='1';
 document.write('<div id="aR_star_info" class="aR_star_info"></div>');
 document.write('<scr'+'ipt type="text/JavaScript" src="http://addratings.com/aR_BootStrap.js"></scr'+'ipt>');
</script>

The site explaned that if I wanted to use the code more than once on the same page, I could, but I would have to define a unique value to + "" part of aR_url=location.href + ""; like this: + "1" for each instance of the code, or all the results would be the same for each instance.

So my question again is "What parts of the scripts do I need to change and what to change them to in order for the result to be a star rating tool under each new guestbook post?", Thanks in advance for any help I may get.


you can have each new post be an instance of star rating so you can have a counter for it for example:

post.js

function post()
{
   var rating; 
   this.increase_rating() = function() {..} 
}

in the main script, var newpost = new post();

then when someone clicks a button to increase star it would [onClick=newpost.increase_rating()]

Well if you copy the src= "http" location you can get the source code for guestbook that you previously could not edit

here it is btw, that you can copy and put into your own .js file and include and edit as you need

var Entries = 3; 
var Title = "book1"; 
var GuestName = new Array(Entries); 
var GuestEmail = new Array(Entries); 
var GuestVote = new Array(Entries); 
var GuestDate = new Array(Entries); 
var GuestWebsite = new Array(Entries); 
var GuestMessage = new Array(Entries); 
var FilledEntries = 0; 

function AddEntry(Name, Date, Email, Vote, Website, Message) 
{
 GuestName[FilledEntries] = unescape(Name); 
 GuestDate[FilledEntries] = unescape(Date); 
 GuestEmail[FilledEntries] = unescape(Email); 
 GuestVote[FilledEntries] = unescape(Vote); 
 GuestWebsite[FilledEntries] = unescape(Website); 
 GuestMessage[FilledEntries] = unescape(Message); 
 FilledEntries++;
} 
AddEntry("RatETest", "6/1/2010 09:29:46 pm", "", "0", "http://", "Rate test 1"); 
AddEntry("Test", "6/1/2010 07:03:07 pm", "", "0", "http://", "Message 2"); 
AddEntry("test1", "6/1/2010 06:21:44 pm", "strangedays@mobilestimulus.com", "5", "http://www.mobilestimulus.com", "Testing the guestbook feature"); 

and you can change this to add the variables inside the function itself, and can make every post an object. Also you can add the features of the other site using the same method, (find the address to their .js or use page source) and put it into this file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜