|
-
Apr 16th, 2001, 09:27 PM
#1
Thread Starter
Fanatic Member
I have this
------------------------------------------
<form name = "Myform">
<select name = "S[1]">
<option value="1">orange
<option value="2">red
</select>
</form>
---------------------------------------
I am using the S[1] because I am passing it off to a PHP script than handles all the "S" selects as an array
---------------------------------------
how can I use javascript to check to value of the select
<Script= "JavaScript">
alert(document.Myform.S[1].value)
</script>
doesn't work
"document.Myform.S.1 is not an object"
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Apr 17th, 2001, 02:39 AM
#2
Perhaps this will give you an idea how to handle JavaScript objects.
Code:
<html>
<head>
<title></title>
<script language=javascript>
<!--
function button_onclick() {
alert( document.myform.s.value )
}
//-->
</script>
</head>
<body>
<form name="myform">
<select name="s">
<option value="1">orange
<option value="2">red
</select>
<input type="button" value="button" id="button" name="button" language=javascript onclick="return button_onclick()">
</form>
</body>
</html>
-
Apr 17th, 2001, 02:46 AM
#3
Frenzied Member
all objects are arrays in html
Code:
<html>
<Script language="JavaScript">
function x(){
alert(document.Myform.S[1].value)
}
</script>
<body>
<form name = "Myform">
<select name = "S"> <!-- this select is S[0] -->
<option value="1">orange
<option value="2">red
</select>
<select name = "S"> <!-- this select is S[1] -->
<option value="1">green
<option value="2">purple
</select>
<input type='button' onclick='x()'
</form>
</body>
</html>
-
Apr 17th, 2001, 09:38 AM
#4
Thread Starter
Fanatic Member
thanks,
I get it but its going to give me a couple of problems.
But I think I will be able to work around it by making my code nice and messy
I need to assign the array values my self
it might not be 0,1,2,3
but it needs to be
445,743,162
but again I can work around this by adding a hidden field that holds the real values for the arrays, so when it is passed off to the script the script knows whats up
S[0]=s[445]
etc
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Apr 17th, 2001, 01:51 PM
#5
Thread Starter
Fanatic Member
Can't get it to work
how do I read the selects in my PHP script
echo S[0];
echo S[1];
I am only receiving the last one
Kurt Simons
[I know I'm a hack but my clients don't!]
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
|