Forum Moderators: open

Message Too Old, No Replies

active input boxes

auto redirect to ceratin input boxes

         

d40sithui

1:57 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



guys this is kind of a weird question.

lets say i have a page with 3 diff inputs displayed

-name
-location
-age

is there a way to automatically make one of the boxes active on page load, meaning the user does not need to click or tab to it(so the user can just start entering data)? im not sure if this is the right area for this question. please let me know. thanks.

-khanh

Habtom

2:01 pm on Jul 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this should work:

<body onload="document.form44.infield.focus()">

Habtom

d40sithui

2:48 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



hey thanks for the reply.
i tried that. doesnt seem to be working.
if the form is retrieve by AJAX (inside div tags) will this still work? if so where should i call it.

DrDoc

4:01 pm on Jul 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right after the form has been input onto the page ...

d40sithui

5:41 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



yea i've tried over and over. i dont think its possible for javascript to register elements inside returned AJAX page.even a simple alert function dont do anything...perhaps someone can prove me wrong?

-khanh

DrDoc

6:36 pm on Jul 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you output the elements onto the page once retrieved using AJAX?

[edited by: DrDoc at 6:36 pm (utc) on July 10, 2007]

Trace

6:50 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



Does the element have an ID? You could use that;

<body onload="document.getElementById('the_Elements_ID').focus()">

d40sithui

7:48 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



thank you for trying to help. here is the basic rundown

heres the line that is generated by ajax and php

echo "<td><input type=text size=3 maxlength=3 id=\"item$item_idcurr\" value=\"$quantity\" onkeyup=\"update_cart('item_id=$item_idcurr&action=update_quantity&new='+this.value);\"> </input></td>\n";

essentially, what this does is it updates the current quantity for this particular item in the cart by calling the update_cart js function, which in turn will call a php script and passes the item_id, action, and the value that is inside this input box. the script will basically spit out the same line(among others), only with the updated quantity. let me know what you guys think.

d40sithui

7:51 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



also, i have this at the end of the php file (thats called by AJAX) which is suppose to select the id, but doesn't =/

echo"<script language=\"javascript\">";
echo "document.getElementById('item'+$item_idcurr).select();";
echo "</script>\n";

DrDoc

11:54 pm on Jul 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is $item_idcurr numeric?

Try changing these lines to:
echo "<script language=\"javascript\">";
echo "document.getElementById('item$item_idcurr').focus();";
echo "</script>\n";

d40sithui

11:01 am on Jul 11, 2007 (gmt 0)

10+ Year Member



yes it is numeric. this doesnt work either.i event tried with static values. thanks though. the weird thing is that the response text or whatever that was returned by AJAX can call its own js function (update_cart). but somehow no other js function will run inside it such as a setFocus function thats created outside the ajax block and then calling it inside the returned ajax content...any other ideas?