•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,575 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,647 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3197 | Replies: 13 | Solved
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
<html>
<head></head>
<body>
<script language="javascript" type="text/javascript">
var set_action = "";
var set_path = "images/";
var set_id="<!--%ID%-->";
var set_spacer = "spacer.gif";
var set_scroll = "f0.gif";
var set_thumb = "f1.gif";
var set_rate1 = "1.gif";
var set_rate2 = "2.gif";
var set_rate3 = "3.gif";
var set_rate4 = "4.gif";
var set_rate5 = "5.gif";
var set_mark1 = "1";
var set_mark2 = "2";
var set_mark3 = "3";
var set_mark4 = "4";
var set_mark5 = "5";
var set_text = "";
var set_submit = "Vote";
//SETTINGS END
var gotkl = 0;
var path = set_path;
var index = 0;
var firstTime = true;
var img_f = new Array();
img_f[0] = new Image();
img_f[1] = new Image();
img_f[0].src= path + set_scroll;
img_f[1].src= path + set_thumb;
//Files with images
var img_p = new Array();
img_p[1] = new Image();
img_p[2] = new Image();
img_p[3] = new Image();
img_p[4] = new Image();
img_p[5] = new Image();
set_spacer =path + set_spacer;
img_p[1].src=path + set_rate1;
img_p[2].src=path + set_rate2;
img_p[3].src=path + set_rate3;
img_p[4].src=path + set_rate4;
img_p[5].src=path + set_rate5;
function imgonload() {
document.id_pn.src = img_p[5].src;
document.id_pn1.src = img_p[5].src;
}
flg = (document.all) ? 0 : 1;
var obj;
var dx,dy;
var flag = false;
var flag1 = false;
function mousedown(ev)
{
if (flg)
{
X=ev.clientX;
Y=ev.clientY;
return false;
}
else
{
X=event.clientX;
Y=event.clientY;
}
}
function mousemove(ev)
{
if (flag)
{
if (flg)
{
X2=ev.clientX;
Y2=ev.clientY;
}
else
{
X2=event.clientX;
Y2=event.clientY;
}
dy=Y2-Y;
var dh=document.id_spacer.height+dy;
if (dh>-1 && document.id_spacer.height+dy<document.id_pn.height-7) {
document.id_spacer.height = document.id_spacer.height+(Y2-Y);
Y=Y2;
};
if (dh<=-1)
{
document.id_spacer.height=1;
}
if (dh>=document.id_pn.height-7)
{
document.id_spacer.height=document.id_pn.height-8;
}
var mark=Math.floor(document.id_spacer.height/(document.id_pn.height/5));
//alert(mark);
mark=5-mark;
document.id_pn.src = img_p[mark].src
document.post_form.rate.value=mark;
//window.status=mark;
return false;
}
else if (flag1)
{
if (flg)
{
X2=ev.clientX;
Y2=ev.clientY;
}
else
{
X2=event.clientX;
Y2=event.clientY;
}
dy=Y2-Y;
var dh=document.id_spacer1.height+dy;
if (dh>-1 && document.id_spacer1.height+dy<document.id_pn1.height-7) {
document.id_spacer1.height = document.id_spacer1.height+(Y2-Y);
Y=Y2;
};
if (dh<=-1)
{
document.id_spacer1.height=1;
}
if (dh>=document.id_pn1.height-7)
{
document.id_spacer1.height=document.id_pn1.height-8;
}
var mark=Math.floor(document.id_spacer1.height/(document.id_pn1.height/5));
//alert(mark);
mark=5-mark;
document.id_pn1.src = img_p[mark].src
document.post_form.rate2.value=mark;
//window.status=mark;
return false;
}
}
function mouseup()
{
obj = null;
flag = false;
flag1 = false;
}
if (flg)
{
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmousedown = mousedown;
document.onmousemove = mousemove;
document.onmouseup = mouseup;
document.write(
"<table border='0' cellspacing='0' cellpadding='0' width='100px'>"+
" <tr>"+
" <td align='center'>"+
" <img align='middle' name='id_pn'>"+
" </td>"+
" <td id='scroll_cell' align='center' valign='top' width='20' background='"+img_f[0].src+"'>"+
"<table border=0 cellspacing='0' cellpadding='0'><tr><td><img border=0 name='id_spacer' width='20' height='0' src='"+set_spacer+"'></td></tr><tr><td><img width='20' height='8' border='0' id='id_pil' src='"+img_f[1].src+" 'style='cursor : hand;' onMouseDown='flag = true;' ></td></table>"+
" </td>"+
" </tr>"+
" <tr>"+
" <td align='center'>"+
" <img align='middle' name='id_pn1'>"+
" </td>"+
" <td id='scroll_cell1' align='center' valign='top' width='20' background='"+img_f[0].src+"'>"+
"<table border=0 cellspacing='0' cellpadding='0'><tr><td><img border=0 name='id_spacer1' width='20' height='0' src='"+set_spacer+"'></td></tr><tr><td><img width='20' height='8' border='0' id='id_pil1' src='"+img_f[1].src+" 'style='cursor : hand;' onMouseDown='flag1 = true;' ></td></table>"+
" </td>"+
" </tr>"+
"<form action='"+set_action+"' method='post' name='post_form'>"+
" <tr>"+
" <td colspan='2' style='padding: 2px' align='center'>"+
" <input style='width:40%' type='submit' value='"+set_submit+"' onclick=\"javascript:alert('rate.value='+document.post_form.rate.value+', rate2.value='+document.post_form.rate2.value)\">"+
" <input type='hidden' name='ID' value='"+set_id+"'><input type='hidden' name='rate' value='5'><input type='hidden' name='rate2' value='5'>"+
" </td>"+
" </tr></form></table>");
imgonload();
</script></body></html>I disagree. This is what you call the copy and paste technique... the code is now double the ugliness, a nicer solution would take a little more typing. But a little less total code.
The use of the element name (to locate dom elements) isn't really supported across browsers, it works now in Firefox, because most pages are written for IE. But I don't know how supported it is across other browsers.
Cheers.
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Flash/Javascript/HTML code for gallery page (Web Development Job Offers)
- converting from javascript to HTML? (Java)
- Capturing data from txt file using JavaScript/HTML (JavaScript / DHTML / AJAX)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Compiler
- Next Thread: Unsolved dropdown menu



Threaded Mode