473,568 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=documen t.form2.xh1.val ue;
var x = new getObj('h1');
texttop += amount;
x.style.top = texttop;
document.form2. xh1.value=textt op;
}
// -->
</SCRIPT>
<input name="xh1l" type="button" class="BodyText "
onclick="javasc ript: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 12467
Ian Davies wrote on 05 aug 2006 in comp.lang.javas cript:
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=documen t.form2.xh1.val ue;
var x = new getObj('h1');
texttop += amount;
x.style.top = texttop;
document.form2. xh1.value=textt op;
}
// -->
</SCRIPT>
<input name="xh1l" type="button" class="BodyText "
onclick="javasc ript: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(2 0)'
value='<'>

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

<script type='text/javascript'>

var texttop = 150;
var h1 = document.getEle mentById('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
1860
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'; document.getElementById('capabilities').style.visibility='hidden'; } function capabilities() {
2
4748
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 : ----------- <div id="index" style="position:absolute; width:200px; height:115px; z-index:1; left:-400px; top: 286px visibility:false;">
0
2166
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 edited and then saved. Currently, after saving the edited transaction and returning to the check register, the repeater control table returns to the...
0
1880
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 edited and then saved. Currently, after saving the edited transaction and returning to the check register, the repeater control table returns to the...
4
1412
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 with out having to create lots of slightly different functions. The code that has now stoped working is below. My javascript is not great and I have...
9
4660
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 (item.ToString().IndexOf("__") != 0) { //Response.Write(item + " = " + Request.Form +
2
1847
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 nothing but of course generates a postback. Now my problem. When clicking on buttonA, the text of the textbox and of the label are modified by...
3
14395
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 dropdownlistA, all the textboxes are filled with the first row values that contains that selected item and gives the number of rows containing this...
9
2035
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" name=tb1 value=""></td> <td><input type="text" name=tb2 value=""></td>
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.