Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text instead of number from textbox 1

Status
Not open for further replies.

ozane

Technical User
Feb 3, 2005
57
TR
there are 4 textboxes on my web site. when a mouse over an image script runs according to the values of the textboxes. (what i want to be)
here is the texboxes.
maxx<input id="maxx" name="maxx" type="text" runat=server /><br />
maxy<input id="maxy" name="maxy" type="text" runat=server />

in order to use them with asp.net i added runat=sever. my script should get the values from several textbox like that and calculate the valuse. my script

function show(e) {
var x=0
var y=0
x=-(-document.form1.minx.value)+((event.offsetX)*(document.form1('ratioX').value))
y=-(-document.form1.maxy.value)+(-(event.offsety)*(document.form1('ratioY').value))
window.status=x + " " + y
document.onmousemove=show;
return true;
}

however, i guess the values from textboxes are coming as text instead of number so it is not calculating the values as number. at the begginning i was having comma problem with the decimal values i replaced the commas with point.
what should i do to get the values as number?
 
Code:
x=-(-parseInt(document.form1.minx.value, 10)) + ((event.offsetX)*(parseInt(document.form1('ratioX').value, 10)))
y=-(-parseInt(document.form1.maxy.value, 10)) + (-(event.offsety)*(parseInt(document.form1('ratioY').value, 10)))

Although why you're mixing form element access methods, I have no idea.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks
tried that but no way. doing nothing now. before, it was giving me right x values no y values, but now x is freezed and giving same value for anywhere y is still same...

x=-(-parseInt(document.form1.minx.value,10))+((event.offsetX)*(parseInt(document.form1.ratioX.value,10)))
y=-(-parseInt(document.form1.maxy.value,10))+(-(event.offsety)*(parseInt(document.form1.ratioY.value,10)))
 
I don't quite know what you are trying to do here... but you might have some luck changing the second line:
Code:
offset[b]Y[/b]
How about a rewrite? I don't know if this is going to work for you... but it certainly breaks down the logic and allows you to debug your code a little better:
Code:
var frmObj = document.form1;
var minX = parseInt(frmObj.minx.value,10);
var maxY = parseInt(frmObj.maxy.value,10);

x = minX + (event.offsetX)*(parseInt(frmObj.ratioX.value,10));
y = maxY - (event.offsetY)*(parseInt(frmObj.ratioY.value,10));

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
now i am trying to get the coordinates of the cursor on the image for onmousedown and onmouseup. however i can just get the onmousedown coordinates. user should click and move cursor like dragging and i wonna get the coordinates of the start and end point coordinates.
but it is really strange that it works just for a small distance than i cant obtain the onmouseup coordinates???? idea??

var x=0
var y=0

function goster(e) {
document.form1.imgMap.onmousemove=move;
document.form1.imgMap.onmousedown=Down;
document.form1.imgMap.onmouseup=Up;
return true;
}

function Down(a,b){
document.form1.zmaxx.value=x;
document.form1.zmaxy.value=y;

}

function Up(a,b)
{
document.form1.zminx.value=x;
document.form1.zminy.value=y;
}

function move(){
x=-(-(document.form1.minx.value))+((event.offsetX)*((document.form1.ratioX.value)))
y=-(-(document.form1.maxy.value))+(-(event.offsetY)*((document.form1.ratioY.value)))
window.status=x + " " + y;

}
 
Is now the time to tell you that your code won't work in any browser other than IE? If you want Firefox, Safari, Netscape, Opera, etc, to work with your code, you'll have to look at utlising a cross-browser event model - something which is fairly easy, but you seem to have neglected.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
yep you right, i neglected it so far. i focused on solving my problems first. then i will take care of it.
any idea about solution for IE?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top