View Full Version : frames problem
janunme
04-09-2007, 10:28 AM
hi to all,
using one program i devided my webpage into two parts. in one of two frames i have a text field. new my question is while loading this page my cursor must and shoud present on text field. is it possible, if possible tell me. i am waiting for you people's reply.
regards
djr33
04-09-2007, 10:35 AM
Without specifics, I'm not sure exactly what needs to happen, but a link to your page would be helpful.
Using javascript, onLoad (in the body tag) can set the focus to a certain element. Can't remember the exact code at the moment, though.
codeexploiter
04-09-2007, 11:14 AM
Place the below mentioned code in the onload event of body of the required page.
document.forms[the_form_index].textbox_field_name.focus();
for example: document.forms[0].tb.focus() will focus the cursor on the text box whose name is tb which is in the first form of the document.
janunme
04-09-2007, 11:47 AM
thanks for your reply
but sorry to say i am not getting the exact output. it may be becose my program only thats why i am posting myu code. please go through once and tell where i am doing mistakes
mycode is as follows
test.html
--------
<html>
<head>
<script language="javascript">
function tes()
{
document.forms[0].t1.focus();
}
function tep()
{
window.alert("hello");
document.forms['f1'].elements['b1'].onClick = function() {tes()}
}
</script>
</head>
<body>
<form name="f1" onload="tes()">
<input type="text" name="t1">
</form>
</body>
</html>
i am waiting for your reply
regards
codeexploiter
04-09-2007, 11:55 AM
Try this one
<html>
<head>
<script language="javascript">
function tes()
{
document.forms[0].t1.focus();
}
function tep()
{
window.alert("hello");
document.forms['f1'].elements['b1'].onClick = function() {tes()}
}
</script>
</head>
<body onload="tes()">
<form name="f1" >
<input type="text" name="t1">
</form>
</body>
</html>
janunme
04-09-2007, 12:18 PM
yes it is working
thanks for your help
now i want to ask another Q related to this only. how to use this one in frames.
regards
mburt
04-09-2007, 12:30 PM
In frames? In what way? Do you want to focus on something in a frame?
janunme
04-09-2007, 07:31 PM
thanks for your reply
it is working for frames(upto my requirement). now i want to ask about frames but different one as follows:
in my project there are 4 forms all are having same fields but on that same form there are four operations are there. they are namely "Insert(it is by default), Update, Delete and Select.
first i developed seperate forms for seperate operations, i worked on that and i understood that i am unnecessarily rewriting code. thats why i am planning to use same form for different operations. but here all operations are different, calling functions are different, different properties.
now my problem is how to change all those properties while pressing the relevent button.
can you guide me how to achive this
regards
mburt
04-09-2007, 07:39 PM
how to change all those properties while pressing the relevent button.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
function change() {
for (var i=0;i<arguments.length;i=i+2) arguments[i].value = arguments[i+1];
}
</script>
</head>
<body>
<form name="myForm">
Insert: <input type="text" name="insert">
<br>Update: <input type="text" name="update">
<br>Delete: <input type="text" name="sdelete">
<br>Select: <input type="text" name="select">
<br><input type="button" value="Change" onclick="
var a=document.forms['myForm'];
change(a.insert,'new insert',
a.update,'new update',
a.sdelete,'new delete',
a.select,'new select')">
</form>
</body>
</html>
The function change() is as follows:
Every 1st argument is the element you want to apply to new text to, every 2nd argument is the text to be applied to the previous element, using the .value attribute.
janunme
04-10-2007, 06:20 PM
hi to all
i am developing a page using jsp and in that i am using script language as javascript. in that page i i have four text boxes and 4 buttons and required records are getting from database using jsp
operations of buttons are "Insert","Update","Delete","Exit". by default it is in Insert Mode. now any one can insert after filling all the details and press "Insert" button. Upto here there is no problem for me. it is working very well.
when ever i want to update my records i am facing problems. inorder to update my details press "Update" button. when ever i press "Update" button it automatically. i am waiting for you peoples replys
regarding
janunme
04-10-2007, 06:45 PM
thanks for your reply
it is working, but it is not working if i wnat to change the function which i wnat to execute. is it possible
if you wnat more clear idea about my problem see the following
Code:
<html>
<head>
<script language="javascript">
function insert()
{
//here i will write code for inserting data into database
}
function update()
{
//here i will write code for updating data into database
}
function delete()
{
//here i will write code for deleting data from database
}
</script>
</head>
<body>
name:<input type=text name="t1"><br>
address<input type=textarea name="ta1"><br>
phone:<input type=text size=15 ><br><br>
<input type="button" onclick="Insert()" value=Insert"><br>
<input type="button" onclick="change()" value=change">
</body>
</html>
after loading this page bydefault button "Insert" function is insert(). now my requirement is when ever i press change button, "Insert" button must change there properties like value "Insert" to "Update", onclick=insert() to onclick=update() and so on.
this is what i want to explain to ypou people. can any one guide me how to do all these things
regards
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.