| | |
Help modify some JavaScript/HTML
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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.
•
•
Join Date: Aug 2005
Posts: 279
Reputation:
Solved Threads: 6
Thanks for your help, and putting up with me.
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.
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.
•
•
Join Date: Aug 2005
Posts: 279
Reputation:
Solved Threads: 6
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
Thanks,
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,
![]() |
Similar Threads
- Capturing data from txt file using JavaScript/HTML (JavaScript / DHTML / AJAX)
- Flash/Javascript/HTML code for gallery page (Web Development Job Offers)
- converting from javascript to HTML? (Java)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Compiler
- Next Thread: Unsolved dropdown menu
Views: 4398 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxexample ajaxhelp ajaxjspservlets array automatically autoplay beta blackjack boarder box button captcha card cart codes column css date debugger decimal design developer dom download element embed enter error events firefox flash focus form frameworks gears getselection google gwt hiddenvalue hint html htmlform ie7 iframe index java javascript javascripthelp2020 javascripts jawascriptruntimeerror jquery jsp libcurl listbox maps marquee masterpage media menu microsoft mimic mp4 offline onerror onmouseover parameters paypal php player position post problem programming prototype rating redirect safari scale scriptlets search security select size software sources starrating toggle tweet unicode validation variables w3c web webkit webservice window windowofwords xml





