paulmason411
Posts: 127
|
| Posted: 10/22/2008, 8:39 PM |
|
Hi Guys,
I often have a form that needs constant updating and isn't at the top of the page. What this means is that each time I update I have to scroll down to the form again. Does codecharge have any prebuilt feature to help resolve this (apart from ajax)?
I look forward to everyones input
_________________
http://paulmason.name - Web Development Blog
|
 |
 |
datadoit
|
| Posted: 10/25/2008, 5:54 PM |
|
You could try setting the focus to a field in your form. In the Page's
BeforeShow, add a client action to Set Focus.
|
|
|
 |
melvyn
Posts: 333
|
| Posted: 10/25/2008, 8:13 PM |
|
Also, you can use the has http://www.yoursite.com.com/yourpage.php#bottomformtitle
The trick is the # which says to the browser "jump to there you find this"
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
paulmason411
Posts: 127
|
| Posted: 10/29/2008, 8:29 PM |
|
Thanks guys, both work well!
_________________
http://paulmason.name - Web Development Blog
|
 |
 |
paulmason411
Posts: 127
|
| Posted: 11/06/2008, 6:54 PM |
|
I have just run into a slight problem:
I am using melvyn's idea (# in url), with a redirect on my forms onclick event.
However when I use form validation, the onclick isn't run unless valid.
Basically the problem comes down to being able to manipulate the url when a validation event is run. Does anyone know how?
_________________
http://paulmason.name - Web Development Blog
|
 |
 |
melvyn
Posts: 333
|
| Posted: 11/06/2008, 7:17 PM |
|
the content in http://www.yoursite.com.com/yourpage.php#bottomformtitle is called the "hash"
http://.....#paulmason <== the hash for htis is paulmason.
You can call the hash with the system var:
window.location.hash
try an alert inside the javascript:
alert(window.location.hash);
to set the hash by code:
window.location.hash = "paulmason"
The above is javasript; your problem is: when an error occur some variables get added to the url in the way http://www.yoursite.com/yourpage.php?ccsForm=your-form-name to indicate that form have errors, and (by the way) cutting the hash.
Now, we need to put the hash there.
<script language="JavaScript" type="text/javascript">
window.onload = window.location.hash = "paulmason1";
</script>
You can insert that line inside a label and only do it visible when needed (when there's a variable ccsForm defined).
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
paulmason411
Posts: 127
|
| Posted: 11/06/2008, 8:01 PM |
|
I just tested this with ie6 and firefox 3.
It works with ie6 but with firefox it doesn't scroll to that position until you refresh the page.
So it adds the # to the url but it seems to be too late, must be the way firefox orders it's processes.
Is there any additional JS to fix this? Thanks for all the help so far
_________________
http://paulmason.name - Web Development Blog
|
 |
 |
melvyn
Posts: 333
|
| Posted: 11/06/2008, 9:08 PM |
|
If a javascript contains an error and stop working, everything after the error get stopped.
As web developer you ***must have*** firebug and css web developer extensions installed in your ffox. What does your firebug says? do it report javascript error in the JS console?
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
paulmason411
Posts: 127
|
| Posted: 11/06/2008, 10:58 PM |
|
There don't seem to be any errors, in fact i can see a green tick in the js console.
Can you try this test in firefox and tell me if it works for you or if you have to reload the page?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Scroll Test</title>
<script language="JavaScript" type="text/javascript">
window.onload = window.location.hash = "scroll_to_me";
</script>
</head>
<body>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<div id="scroll_to_me">
This text should be visible when the page is first loaded.
</div>
</body>
</html>
That should be enought <br \>'s to cause your screen to scroll. Add some more if your screen res is too big.
It does create the # but the page needs refreshing for it to work.
Let me know how you go. Cheers.
_________________
http://paulmason.name - Web Development Blog
|
 |
 |
melvyn
Posts: 333
|
| Posted: 11/07/2008, 6:57 AM |
|
Hello feha.
Not enough <br />'s my screen is 1680x1050. Resized my browsers window.
The bad news: It works in IE7, don't work in FF3.
The good news: It appear to be a bug in FF. Why? Let's see:
It's well known that when javascript is executing it stop all page rendering until js code is finalized. It appears that ffox executes javascript in the order it find in the page (that sounds correct); the matter is: when this js is executed there's no html in the page, so, there's nothing to apply.
Try this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Scroll Test</title>
</head>
<body>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<div id="scroll_to_me">
This text should be visible when the page is first loaded.
</div>
<script language="JavaScript" type="text/javascript">
window.onload = window.location.hash = "scroll_to_me";
</script>
</body>
</html>
Now it works. Why? because the code is rendered first and javascript is executed after the html is loaded.
This is a practice common in yahoo and recommended by them (yahoo yui and yslow teams).
Well, that solve the yours and print the page faster. Test it
Melvyn
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
paulmason411
Posts: 127
|
| Posted: 11/10/2008, 6:09 PM |
|
That did the trick, thanks Mel.
_________________
http://paulmason.name - Web Development Blog
|
 |
 |