Bit of a stupid question...I really should know this

Spacemail by SpaceshipSpacemail by Spaceship
Watch

adam_uk

Established Member
Impact
20
hey people

im building a script and its gonna have a drop down menu with 1 - 100

when they add there age it gets entered into a database ive done that

now when they visit the page again i want the value of the age (say 34) selected so if there 34 when they visit the page 34 is selected

ive totally forgot

ive googled but no such luck :o :D ;)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
     window.myform.myselect.value = 36;
//-->
</SCRIPT>
<NOSCRIPT>
<!-- error -->
</NOSCRIPT>

change the objects to the form and select objects in your document.
 
0
•••
that didnt seem to work

Code:
<form name='form11' method='post' action=''>
<select name='age11'>
<option value=''></option>
<option value='36'>36</option>
<option value='bob' >bob</option>
</select></form>

thats my select box

it goes all the way from 1-100, i took them out basically because it would take up to much space here but you get the idea plus ive taken out all the other boxes n stuff

and my code i modifed is

Code:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
     window.form11.age11.value = 36;
//-->
</SCRIPT>
<NOSCRIPT>
<!-- error -->
</NOSCRIPT>

it doesnt seem to do anything it always leaves the first feild selected
 
0
•••
admins, can i get my name changed to worlds biggest plonker?

ive had the awnser in front of me for since sunday!!!!!!! :o


thanks for your help Mp)Tarh
 
0
•••
Originally posted by adam_uk
admins, can i get my name changed to worlds biggest plonker?

ive had the awnser in front of me for since sunday!!!!!!! :o


thanks for your help Mp)Tarh
Sure, we can change it if you want. :D

Hmm isn't something like this:

<option value="34" selected>34</option>

what you were looking for? Simply how to have a certain option selected by default?
 
0
•••
Originally posted by deadserious
Sure, we can change it if you want. :D

Hmm isn't something like this:

<option value="34" selected>34</option>

what you were looking for? Simply how to have a certain option selected by default?

in a way yes, but the value can change depending on an option inside a database

i sussed it with this
PHP:
$form="<select name='age'>";						  
$x = 0;
while( $x < 100 ){
	if($x == "$age") {
		$bob = "SELECTED";
	}else{ 
		$bob = "";
	} 
$form .=  "<option value='$x' $bob>$x</option>";
$x++; 
}
$form .= "</select>";

$age = the value of the database
 
0
•••

We're social

Spaceship
Domain Recover
CatchDoms
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back