473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

using javascript to move text on clicking a button

I am trying to move some text by clicking a button. When clicked the button
runs the java script and this will then take the value in the text field and
add 10 to it to create a new value, this is then used to move the text
(id=h1) to a new position and to display the new value in a text field. My
script is below but does not work. Im new to javascrip and there is probably
something embarasingly obviour that Im missing. Can anyone help
Ian
<SCRIPT TYPE="text/javascript">
<!--
function move(amount) {
var texttop=document.form2.xh1.value;
var x = new getObj('h1');
texttop += amount;
x.style.top = texttop;
document.form2.xh1.value=texttop;
}
// -->
</SCRIPT>
<input name="xh1l" type="button" class="BodyText"
onclick="javascript:move(10)" value="<">

<input name="xh1" type="text" class="BodyText" value="<?php echo
$row['xh1']; ?>" size="1">

<div id="h1">some text</div>
Aug 4 '06 #1
1 12412
Ian Davies wrote on 05 aug 2006 in comp.lang.javascript:
I am trying to move some text by clicking a button. When clicked the
button runs the java script and this will then take the value in the
text field and add 10 to it to create a new value, this is then used
to move the text (id=h1) to a new position and to display the new
value in a text field. My script is below but does not work. Im new to
javascrip and there is probably something embarasingly obviour that Im
missing. Can anyone help Ian
<SCRIPT TYPE="text/javascript">
<!--
function move(amount) {
var texttop=document.form2.xh1.value;
var x = new getObj('h1');
texttop += amount;
x.style.top = texttop;
document.form2.xh1.value=texttop;
}
// -->
</SCRIPT>
<input name="xh1l" type="button" class="BodyText"
onclick="javascript:move(10)" value="<">

<input name="xh1" type="text" class="BodyText" value="<?php echo
$row['xh1']; ?>" size="1">

<div id="h1">some text</div>
Try this, IE6 tested:

=====================================

<input type='button'
onclick='move(20)'
value='<'>

<div id='h1'
style='position:absolute;top:150px;left:150px;'>
some text</div>

<script type='text/javascript'>

var texttop = 150;
var h1 = document.getElementById('h1');

function move(amount) {
texttop += amount;
h1.style.top = texttop+'px';
}

</script>

=======================================

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Dafydd | last post by:
I have the following Script in my web page reduce to two pages. <script> function details() { document.getElementById('details').style.visibility='visible';...
2
by: Nasir Wasim | last post by:
How can Access DIV Properties in Script while using Netscape 7.2. I want to use the div id with it's Visibility and left propertyin script but it's not working :-( Main File : ----------- ...
0
by: Keith | last post by:
I have a web form that contains a repeater control that is designed to ask like a check book register. Clicking on a certain transaction takes the user to a different .aspx page where it can be...
0
by: Keith | last post by:
I have a web form that contains a repeater control that is designed to ask like a check book register. Clicking on a certain transaction takes the user to a different .aspx page where it can be...
4
by: mantrid | last post by:
Hello Hope you can help. I have been using the code below to move elenents around the page. This has worked fine until I put some arguments into the functions so I could use them in many places...
9
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach (object item in Request.Form) { if...
2
by: Phil | last post by:
Hi, There is a label and a textbox. There are two buttons: one HTML (buttonA), the other ASP.NET (ButtonB). Clicking on buttonA starts a javascript function, starting on ButtonB triggers...
3
by: dianaj86 | last post by:
I have multiple dropdownlists each one filled with values from a specific column in the table. Also I have multiple textboxes corresponding to dropdownlists. For example, when I select an item from...
9
by: TechnoAtif | last post by:
<form name=frm action="" method="post"> <table> <tr><td><select name=combo> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <td><input type="text"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.