User Name Password Register
DaniWeb IT Discussion Community
All
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 370,600 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 2,047 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: 2921 | Replies: 13 | Solved
Reply
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Help modify some JavaScript/HTML

  #11  
Jun 22nd, 2006
<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.
Reply With Quote  
Join Date: Aug 2005
Posts: 276
Reputation: J_Search is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 6
J_Search J_Search is offline Offline
Posting Whiz in Training

Re: Help modify some JavaScript/HTML

  #12  
Jun 22nd, 2006
Thanks for your help, and putting up with me.
J_
Reply With Quote  
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Help modify some JavaScript/HTML

  #13  
Jun 22nd, 2006
That's cool, I get bored at work. as a rule of thumb, the easier it is for people to access the problem, the easier it is for them to help.

If I can glance at the code and see I can paste it into a webpage without editing it, I will, even if I have no idea what the problem is! So what you did with a zip was handy, as the images are rather important sometimes too.

Everything you have mentioned is doable, as always, a problem has many solutions.

Have fun.
Reply With Quote  
Join Date: Aug 2005
Posts: 276
Reputation: J_Search is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 6
J_Search J_Search is offline Offline
Posting Whiz in Training

Re: Help modify some JavaScript/HTML

  #14  
Jun 23rd, 2006
alpha_foobar,

I hate to beat a dead horse, but...

I created rater2 with mouseover rather than mouse drag. Do you think this will work too? I only found one problem. If you mouseover and click on one of the numberes, then mouse over the link to display the rating, it will display the javascript alert twice. If I used
<input type='hidden' name='rate' value='"+rate+"'> do you think it will cause an issue with double votes like the javascript alert has?

Thanks,
Attached Files
File Type: zip rater2.zip (5.8 KB, 1 views)
J_
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:23 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC