473,595 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using arguments in functions. what am I doing wrong?

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 been struggling with this all day. Can
anyone see where Ive gone wrong

Thanks
Ian
This first bit is two elements that will be dynamically moved around by
pressing buttons on a form (I have many of these but have only shown two).

*******code starts here*********** ****

<div id='h1' style='position :absolute;left: <?php echo $xh1/2;?>px; top:<?php
echo $yh1/2;?>px; font-size:<?php echo $sh1/2;?>px; visibility:
visible;'><?php echo wordwrap($h1,$w h1, "<br />\n"); ?></div>
<div id='h2' style='position :absolute;left: <?php echo $xh2/2;?>px; top:<?php
echo $yh2/2;?>px; font-size:<?php echo $sh2/2;?>px; visibility:
visible;'><?php echo wordwrap($h2,$w h2, "<br />\n"); ?></div>

*************** *************** *************** *************** *************** *
*
These are the functions which do the moving. They have 3 arguments, one for
the number of pixels to move each time, one for the textfield that stores
the elements position, and one for the id of the element to be moved. Ive
used arguments in the functions instead of the actual values so that I can
reuse the functions with other blocks.

***code starts here *****

<script type="text/javascript" language="javas cript">
<!--
/*var texttop=100;*/
var h1 = document.getEle mentById('h1');
var textleft =120;
var texttop = 0;

function ymove(amount,yp osition,textstr {
texttop += amount;
textstr.style.t op =texttop+'px';
document.form2. yposition.value = texttop*2;

}

function xmove(amount,xp osition,textstr ) {
textleft += amount;
textstr.style.l eft =textleft+'px';
document.form2. xposition.value = textleft*2;
}
//-->
</script>
*************** *************** *************** *************** *************

This final bit is two buttons on either side of a text field, and when they
are clicked they call on the functions above. These then change the left and
top positions of the elements (the first bit of code)
I have a number of these blocks (only one shown below) each acting to move
an element around and storing its position in the textfield.

******code starts here*********** ***

<input name="button23" type='button' class="BodyText "
onClick="xmove(-10,'xh1,'h1')"
value='&lt;'>
<input name="xh1" type="text" class="BodyText " value="<?php echo
$xh1; // echo $row['xh1']; ?>" size="1">
<input name="button22" type='button' class="BodyText "
onClick="xmove( 10,'xh1,'h1')"
value='>'>
</div></td>
<td nowrap class="BodyText "><div align="center">
<input name="button" type='button' class="BodyText "
onClick="ymove(-10,'yh1','h1')"
value='<'>
<input name="yh1"type= "text" class="BodyText " value="<?php echo $yh1;
?>" size="1">
<input name="button2" type='button' class="BodyText "
onClick="ymove( 10,'yh1','h1')"
value='>'>
Aug 6 '06 #1
4 1413
In article <aL************ *****@newsfe4-win.ntli.net>,
ia********@virg in.net says...
Hello
Hope you can help. I have been using the code below to move elenents around
the page.
It would help if you posted clearly formatted, client-side code, not
your PHP source.

--
Hywel
http://kibo.org.uk/
Aug 6 '06 #2
mantrid wrote:
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 been struggling with this all day. Can
anyone see where Ive gone wrong
I haven't tested you code, below are some suggestions...

[...]
***code starts here *****

<script type="text/javascript" language="javas cript">
<!--
Ditch the deprecated language attribute (keep type) and get rid of the
HTML style comment delimiters.

/*var texttop=100;*/
var h1 = document.getEle mentById('h1');
var textleft =120;
var texttop = 0;

function ymove(amount,yp osition,textstr {
texttop += amount;
textstr.style.t op =texttop+'px';
document.form2. yposition.value = texttop*2;

}

function xmove(amount,xp osition,textstr ) {
textleft += amount;
textstr.style.l eft =textleft+'px';
document.form2. xposition.value = textleft*2;
}
//-->
</script>
*************** *************** *************** *************** *************

This final bit is two buttons on either side of a text field, and when they
are clicked they call on the functions above. These then change the left and
top positions of the elements (the first bit of code)
I have a number of these blocks (only one shown below) each acting to move
an element around and storing its position in the textfield.

******code starts here*********** ***

<input name="button23" type='button' class="BodyText "
onClick="xmove(-10,'xh1,'h1')"
You have unbalanced parenthesis here...

value='&lt;'>
<input name="xh1" type="text" class="BodyText " value="<?php echo
$xh1; // echo $row['xh1']; ?>" size="1">
<input name="button22" type='button' class="BodyText "
onClick="xmove( 10,'xh1,'h1')"
And here. There may be other problems.

[...]

--
Rob
Aug 6 '06 #3
>You have unbalanced parenthesis here...

Unfortunately they were just typo errors in my post.
"RobG" <rg***@iinet.ne t.auwrote in message
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au ...
mantrid wrote:
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 been struggling with this all day.
Can
anyone see where Ive gone wrong

I haven't tested you code, below are some suggestions...

[...]
***code starts here *****

<script type="text/javascript" language="javas cript">
<!--

Ditch the deprecated language attribute (keep type) and get rid of the
HTML style comment delimiters.

/*var texttop=100;*/
var h1 = document.getEle mentById('h1');
var textleft =120;
var texttop = 0;

function ymove(amount,yp osition,textstr {
texttop += amount;
textstr.style.t op =texttop+'px';
document.form2. yposition.value = texttop*2;

}

function xmove(amount,xp osition,textstr ) {
textleft += amount;
textstr.style.l eft =textleft+'px';
document.form2. xposition.value = textleft*2;
}
//-->
</script>
*************** *************** *************** *************** *************

This final bit is two buttons on either side of a text field, and when
they
are clicked they call on the functions above. These then change the left
and
top positions of the elements (the first bit of code)
I have a number of these blocks (only one shown below) each acting to
move
an element around and storing its position in the textfield.

******code starts here*********** ***

<input name="button23" type='button' class="BodyText "
onClick="xmove(-10,'xh1,'h1')"

You have unbalanced parenthesis here...

value='&lt;'>
<input name="xh1" type="text" class="BodyText " value="<?php
echo
$xh1; // echo $row['xh1']; ?>" size="1">
<input name="button22" type='button' class="BodyText "
onClick="xmove( 10,'xh1,'h1')"

And here. There may be other problems.

[...]

--
Rob

Aug 6 '06 #4
You can see what Im trying to do at the following.

http://www.iddsoftware.co.uk/test.php

You can check the source and get a better idea of whats going on

Thanks again this one got me stumped and I dont really want to write lots of
little functions, its not very elegant
Ian
"mantrid" <ia********@vir gin.netwrote in message
news:oU******** ****@newsfe3-win.ntli.net...
You have unbalanced parenthesis here...

Unfortunately they were just typo errors in my post.
"RobG" <rg***@iinet.ne t.auwrote in message
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au ...
mantrid wrote:
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 been struggling with this all
day.
Can
anyone see where Ive gone wrong
I haven't tested you code, below are some suggestions...

[...]
***code starts here *****
>
<script type="text/javascript" language="javas cript">
<!--
Ditch the deprecated language attribute (keep type) and get rid of the
HTML style comment delimiters.

/*var texttop=100;*/
var h1 = document.getEle mentById('h1');
var textleft =120;
var texttop = 0;
>
function ymove(amount,yp osition,textstr {
texttop += amount;
textstr.style.t op =texttop+'px';
document.form2. yposition.value = texttop*2;
>
}
>
function xmove(amount,xp osition,textstr ) {
textleft += amount;
textstr.style.l eft =textleft+'px';
document.form2. xposition.value = textleft*2;
}
//-->
</script>
>
*************** *************** *************** *************** *************
>
This final bit is two buttons on either side of a text field, and when
they
are clicked they call on the functions above. These then change the
left
and
top positions of the elements (the first bit of code)
I have a number of these blocks (only one shown below) each acting to
move
an element around and storing its position in the textfield.
>
******code starts here*********** ***
>
<input name="button23" type='button' class="BodyText "
onClick="xmove(-10,'xh1,'h1')"
You have unbalanced parenthesis here...

value='&lt;'>
<input name="xh1" type="text" class="BodyText " value="<?php
echo
$xh1; // echo $row['xh1']; ?>" size="1">
<input name="button22" type='button' class="BodyText "
onClick="xmove( 10,'xh1,'h1')"
And here. There may be other problems.

[...]

--
Rob


Aug 6 '06 #5

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

Similar topics

2
8205
by: Steven D'Aprano | last post by:
I'm trying to keep an open mind, but I am perplexed about something in Python that strikes me as a poor design. py> def func(a,b): py> print a,b py> func(1) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: func() takes exactly 2 arguments (1 given)
7
3537
by: Ireneusz SZCZESNIAK | last post by:
I want to sort a vector with the std::sort function. There are two functions: one with two arguments, the other with three arguments. I am using the one with three arguments. I noticed that there is a huge overhead of using this function, which comes from copying the function object, i.e., the object that compares the elements of the vector, which is passed to the function not by reference but by value. Now, at the end of this mail...
6
15202
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I am doing wrong? Your help will be much appreciated. Thanks
121
9990
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
19
78800
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not find one.
41
2537
by: Telmo Costa | last post by:
Hi. I have the following code: -------------------------------------- function Tunnel() { //arguments(???); } function Sum() { var sum = 0; for (i=0; i<arguments.length; i++) sum += arguments;
89
6013
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
36
2693
by: Pacific Fox | last post by:
Hi all, haven't posted to this group before, but got an issue I can't work out... and hoping to get some help here ;-) I've got a base object that works fine with named arguments when called on it's own. However when I call the child object I get an error " has no properties (in firefox)." I simple test:
29
3636
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a string to a integer number. bool Convert(const string& str, int* pData); bool Convert(const string& str, int& data);
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8262
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8020
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8252
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5421
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
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
1491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.