|
-
Jun 9th, 2005, 08:26 AM
#1
JavaScript question...simple to anyone who know JS
I have a function:
Code:
function RebuildStartTimeDropDownCallBack()
{
var StartTimeIndex = document.main.StartTime.selectedIndex
'do some code
document.main.StartTime.selectedIndex = StartTimeIndex
}
However, I don't want to store, and restore the index.
I'd like to get the item data, and then select the combo item that has the same item data that I stored after I have done "Some other code". Item data is unique from a DB (Primary key ID)
Woka
-
Jun 9th, 2005, 09:01 AM
#2
Re: JavaScript question...simple to anyone who know JS
Urgh I dont know any JS but I'll try to help 
Could you maybe do this
Code:
function RebuildStartTimeDropDownCallBack()
{
var StartTimeData = document.main.StartTime.value
'do some code
for (i=0, document.main.StartTime.length, i++) //Dunno about the .length
if (document.main.StartTime.thing[i] == StartTimeData) {
/* The .thing obviously you replace with whatever the JS
equivalent of VB's .List(i) would be */
document.main.StartTime.selectedIndex = i
}
}
}
? I know thats probably useless, I'm no good with Javascript.
-
Jun 9th, 2005, 09:05 AM
#3
Re: JavaScript question...simple to anyone who know JS
Code:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script>
function changeIt(){
//select the item with option value of 3 ie this will be you DB PK
document.frm.sel.options.value = 3;
}
</script>
</head>
<body>
<form name="frm">
<select name="sel">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
<option value="5">five</option>
</select>
<input type="button" value="click" onclick="changeIt();">
</body>
</html>
Edit:
bugger need to try again that dosn't work with firefox.
-
Jun 9th, 2005, 09:17 AM
#4
Re: JavaScript question...simple to anyone who know JS
ok dokey this seems to work in both (if this is what your looking for not entirely sure)
Code:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script>
function changeIt(){
//select item with option value of c
document.frm.sel.value = "c";
}
</script>
</head>
<body>
<form name="frm">
<select name="sel">
<option value="a">one</option>
<option value="b">two</option>
<option value="c">three</option>
<option value="d">four</option>
<option value="e">five</option>
</select>
<input type="button" value="click" onclick="changeIt();">
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|