SEO Class in Chicago, IL
Learn How To Optimize Your Website on July 26, 2013
High Rankings is offering a 1-day customized SEO training class in Chicago. Class size is limited so please sign-up now if you want in!
Are you a Google Analytics enthusiast?
Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE!

www.CustomReportSharing.com
From the folks who brought you High Rankings!
More SEO Content
Getting Drop Down Values In The Form
#1
Posted 12 August 2008 - 04:45 AM
#2
Posted 12 August 2008 - 05:29 AM
How are you trying to access the data? Javascript perhaps? , is it a problem server side, is it the way you are merging data to a template.
Are you using the GET method on the form?
Is the data missing when emailed to you.
Need much more info on what your are actually doing, how you are trying to do it and what the end results you are looking for.
Sorry, couldn't help at this stage.
#3
Posted 12 August 2008 - 06:47 AM
#4
Posted 12 August 2008 - 07:10 AM
I assume you have given the textarea a name as well as the select list, and you correctly capture the data and re-display it with the form.
Don't forget text area 'value' attribute is not the place to put the entered data, you need to place the entered data between the textarea open and close tag
#5
Posted 12 August 2008 - 08:22 AM
#6
Posted 12 August 2008 - 08:58 AM
what program are you using / language to capture the submitted form data?
on the server side if you are capturing the data in the standard POST data buffer in value pairs, but then want to redisplay the form and highlight the selected option that becomes a lot harder.
You can do it in a number of ways, I use a templating system with PERL as my backend/serverside CGI language, it's very powerful and enables you to do very easiliy what you want as well as enabling code/content separation, as CSS does for HTML.
Firstly I grab the content for the seledt list from a DB or CSV string...
use constant LOAN_TYPE => "Secured,Unsecured,Bridging";
#split out into array
my @loan_type = split(/,/,LOAN_TYPE);
#loop array
for(@loan_type){
# turn into hash
$_ = {'Loan Type' => $_};
#compare with form data
if($_->{'Loan Type'} eq $cgi->param('loan_type')){
# if match add selected HTML code to hash
$_->{'sel'} = " selected=\"selected\" ";
}
}
# output array of hashes to form
$template->param( 'loan_type' => \@loan_type );
ok don't bog yourself down with the code , but I hope you get the idea you need to process the list, work out what was selected, mark that option then in the actual HTML template..
<option value="">Please Select</option>
<!--tmpl_loop name='loan_type'-->
<option value="<tmpl_var name='Loan Type'>" <tmpl_var name='sel'> ><!--tmpl_var name='Loan Type'--></option>
<!--/tmpl_loop-->
</select>
this can be tedious and long winded, but when you get your head round it it's easy and very powerful.
The other way of course is to use Javascript, this does mean JS must be enabled or a browser with JS capabilities, so it's up to you, but if you know what option is selected you can use JS to select the option again..
function Querystring_get(key, default_) {
if (default_ == null) default_ = null;
var value=this.params[key]
if (value==null) value=default_;
return value
}
// set advice request prodcut enquiry
function getProduct() {
var qs = new Querystring()
var rq = qs.get("RQ", "")
var sel = document.getElementById('reason');
sel.disabled = false;
for(i=1;i<sel.length; i++){
if(sel.options[i].value == rq){
sel.options[i].selected = true;
sel.disabled = true;
}
}
}
I use this to get the value from the querystring, loop the 'reason' select list on the form and select the option which matches the query string value.
hope this makes sense
Edited by 1dmf, 12 August 2008 - 09:11 AM.
#7
Posted 12 August 2008 - 09:07 AM
in asp coding
Client=request("text1")
<td><select name="text1" class="form" id="text1">
<option value="P" <% if "P"=Client then response.write "selected"%>>Products</option>
<option value="S" <% if "S"=Client then response.write "selected"%>>Service</option>
<option value="D" <% if "D"=Client then response.write "selected"%>>Distributor</option>
<option value="C" <% if "C"=Client then response.write "selected"%>>Customer</option>
</select></td>
#8
Posted 12 August 2008 - 09:19 AM
I'll have a quick search after my meeting, but I think someone with ASP skills needs to help
#9
Posted 12 August 2008 - 10:03 AM
you might also need to trim the var...
<option value="P" <% if trim(Client) = "P" then response.write "selected"%>>Products</option>
#10
Posted 13 August 2008 - 02:19 AM
#11
Posted 13 August 2008 - 03:29 AM
Glad you could work it out
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









