Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Form drop down option/select help
Old 11-28-2007, 06:39 PM Form drop down option/select help
Junior Talker

Posts: 4
Trades: 0
Hi all, brand new here and desperate for help.

I have a two field form, one text and one drop down. When the form is submitted the value in the text field remains, but the value of the selected drop down option is set back to the default. How can I retain the drop down value selected by the user after the form is submitted?

[edited to add] This drop down field has over a hundred options. Currently when a user clicks on the drop down they see about a third of the options with a scroll bar. Is it possible to set the number to show to higher number? I'm not talking about the initial number, I want that to remain one.[end edit]

I'm capable in html, but mostly cut 'n paste with JS or PHP so please be patient with me.

Thanks in advance.

Bob

(I wasn't sure if this was the best place to post this question, so if another forum is more appropriate please direct me to that location.)

Last edited by AK Bob; 11-28-2007 at 07:05 PM.. Reason: Added another question
AK Bob is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-28-2007, 07:10 PM Re: Form drop down option/select help
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
Could you paste your code here?
Nathand is offline
Reply With Quote
View Public Profile
 
Old 11-28-2007, 07:30 PM Re: Form drop down option/select help
Junior Talker

Posts: 4
Trades: 0
Sure. Here it is
<-----

<form action="criminal_results_new.html" id="searchbox_004801452915364305003:k2xmdthqe8a" name="searchbox_004801452915364305003:k2xmdthqe8a" target="_top">
<input type="hidden" name="cx" value="004801452915364305003:k2xmdthqe8a" />
<input type="text" name="q" size="32" id="txt" value="Click Here To Enter Name" onblur="if(this.value.length == 0) this.value='Click Here To Enter Name';" onclick="if( this.value == 'Click Here To Enter Name') this.value='';" />
<input type="hidden" name="cof" value="FORID:11" />
<select name="as_epq">
<option value="">Background Options</option>
<option value="" class="optionstyle">COURT RELATED</option>
<option value="Accused">Accused</option>
<option value="Charges">Charges</option>
<option value="Convicted">Convicted</option>
<option value="Conviction">Conviction</option>
<option value="County Court">County Court</option>
<option value="County District Court">County District Court</option>
</select>&nbsp;&nbsp;
<input type="submit" name="sa" value="Search" />
</form>
------>

I deleted most of the options to conserve space. Thanks for your help/time.

Bob

Last edited by AK Bob; 11-28-2007 at 07:32 PM.. Reason: needed to remove some text
AK Bob is offline
Reply With Quote
View Public Profile
 
Old 11-28-2007, 07:34 PM Re: Form drop down option/select help
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
Ok, so I'm guessing that's not all of your options since you said there were over 100, but to select an option from a select box just add
Code:
selected="selected"
Immediately after an options value.

So if you wanted "County Court" to be selected you would go:
Code:
<form action="criminal_results_new.html" id="searchbox_004801452915364305003:k2xmdthqe8a" 

name="searchbox_004801452915364305003:k2xmdthqe8a" target="_top">
<input type="hidden" name="cx" value="004801452915364305003:k2xmdthqe8a" />
<input type="text" name="q" size="32" id="txt" value="Click Here To Enter Teacher Name" onblur="if(this.value.length == 0) 

this.value='Click Here To Enter Teacher Name';" onclick="if( this.value == 'Click Here To Enter Teacher Name') this.value='';" />
<input type="hidden" name="cof" value="FORID:11" />
<select name="as_epq">
<option value="">Background Options</option>
<option value="" class="optionstyle">COURT RELATED</option>
<option value="Accused">Accused</option>
<option value="Charges">Charges</option>
<option value="Convicted">Convicted</option>
<option value="Conviction">Conviction</option>
<option value="County Court" selected="selected">County Court</option>
<option value="County District Court">County District Court</option>
</select>&nbsp;&nbsp;
<input type="submit" name="sa" value="Search" />
</form>
Nathan

Last edited by Nathand; 11-28-2007 at 07:37 PM..
Nathand is offline
Reply With Quote
View Public Profile
 
Old 11-28-2007, 07:46 PM Re: Form drop down option/select help
Junior Talker

Posts: 4
Trades: 0
I didn't explain my problem very well. I want the selected option to remain AFTER the form is submitted and not revert to the default selected="selected". In other words if a user selects "County Courts" and submits the form I want "County Courts" to remain selected until another option is selected by the user.

I hope that explains my question better. And yes, I did remove most of the options since it's just repetitive.


Thanks again for your help.

Bob
AK Bob is offline
Reply With Quote
View Public Profile
 
Old 11-28-2007, 07:50 PM Re: Form drop down option/select help
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
You explained perfectly, I didn't. Here's what I ended up doing with a select box a while back:

Code:
<form method="post" action="<?php echo ($_SERVER['PHP_SELF'] . "?id=" . $reviewid); ?>">
<select name="watched">
<?php
if($row[2] == 1){ $selectIfWatched = 'selected="selected"'; } else { $selectIfWatched = ""; }
echo('<option value="0">Haven\'t watched yet</option><option value="1" ' . $selectIfWatched . '>Yes, I\'ve seen this film</option>');
?>
</select>
<a href="./delete.php?id=<?php echo($reviewid);?>">Delete</a> 
</form>
So the only way I know of doing it, is to "echo" it out at the appropriate spot.

Nathan
Nathand is offline
Reply With Quote
View Public Profile
 
Old 11-28-2007, 08:05 PM Re: Form drop down option/select help
Junior Talker

Posts: 4
Trades: 0
Thanks Nathan, with my limited knowledge of PHP I think that solution would/could work for me. The problem is that with my limited knowledge of PHP I don't how to adapt to my form. But thanks for the help. At least it give's me a starting point to work from.

Bob
AK Bob is offline
Reply With Quote
View Public Profile
 
Old 11-28-2007, 08:31 PM Re: Form drop down option/select help
holly123890's Avatar
Experienced Talker

Posts: 31
Name: holly
Location: ummmmmm lol i cant tell you
Trades: 0
uhhh how come i put up a question and i only get like 3 reply and every one esle gets like 6 or 10 lol im just kidding its mostly my fault becasue they cant ready my grammer and spelling lol
holly123890 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Form drop down option/select help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.05670 seconds with 12 queries