High Rankings Search Engine Optimization ForumHigh Rankings Advisor Search Marketing Newsletter

Welcome Guest ( Log In | Register )

Important Announcement: ***Need an Affordable SEO Website Review?***
 
Reply to this topicStart new topic
> Getting Drop Down Values In The Form
seo_bright
post Aug 12 2008, 04:45 AM
Post #1


HR 5
*****

Group: Active Members
Posts: 290
Joined: 8-June 05
User's local time:
Feb 9 2010, 04:07 PM
Member No.: 7,688



I am working on a feedback page for a client. In that one, we have a drop down text field and containing 4 options. Suppose the customer types in a field wrongly, the fields before that have to appear the same as they where previously entered. While we are able to fetch text values we are having problems with accessing the values for the drop down box. Also the comments which are given in Text Area also is not displaying. Does anyone have an idea on this. I have searched a lot on this topic but could not find a result to this.
Go to the top of the page
 
+Quote Post
1dmf
post Aug 12 2008, 05:29 AM
Post #2


Keep Asking, Keep Questioning, Keep Learning
*******

Group: Active Members
Posts: 1,950
Joined: 24-May 07
User's local time:
Feb 9 2010, 08:07 PM
From: Worthing - England
Member No.: 17,339



I don't understand your question.

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.

Go to the top of the page
 
+Quote Post
seo_bright
post Aug 12 2008, 06:47 AM
Post #3


HR 5
*****

Group: Active Members
Posts: 290
Joined: 8-June 05
User's local time:
Feb 9 2010, 04:07 PM
Member No.: 7,688



I am sorry you could not understand. Actually I am trying to validate a feedback form. There are text boxes, then <textarea>, then drop down menu <select>. Only after all values are correct and validated it gets submitted. We have used the same asp page for postabacking also. Suppose a user misses the email id text box, and clicks submit button a message to enter the values should come. Along with that whatever the user had typed earlier should also get displayed in the respective text boxes. We are able to retrieve and display the text box values in the postback form, but we are unable to get the drop down value and textarea values from the form. But when submit button is clicked it loads with default values as like a fresh form with no values in text area and default selection for drop down menu. But client wants to display those values that are already entered before when the form was reloaded during validation. Hope you get my point.

Go to the top of the page
 
+Quote Post
1dmf
post Aug 12 2008, 07:10 AM
Post #4


Keep Asking, Keep Questioning, Keep Learning
*******

Group: Active Members
Posts: 1,950
Joined: 24-May 07
User's local time:
Feb 9 2010, 08:07 PM
From: Worthing - England
Member No.: 17,339



can you give a URL so i can look at the code?

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
Go to the top of the page
 
+Quote Post
seo_bright
post Aug 12 2008, 08:22 AM
Post #5


HR 5
*****

Group: Active Members
Posts: 290
Joined: 8-June 05
User's local time:
Feb 9 2010, 04:07 PM
Member No.: 7,688



Thank you 1dmf that idea worked. I tried putting it in a value tag. Similarly how to get values from drop down. Is there any easy way without use of sessions and all. I have kept a value attribute for each drop down but how to assign them in the same form. Any ideas plz. I am searching for a clue in other forums there is just no response even if it is prog forum.










Go to the top of the page
 
+Quote Post
1dmf
post Aug 12 2008, 08:58 AM
Post #6


Keep Asking, Keep Questioning, Keep Learning
*******

Group: Active Members
Posts: 1,950
Joined: 24-May 07
User's local time:
Feb 9 2010, 08:07 PM
From: Worthing - England
Member No.: 17,339



how are you capturing the data? is the form a GET method? javascript? serverside.

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...
CODE
# constant which holds select list options
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..

CODE
    <select id="loantype" name="loantype" onchange="check_loan_type(this)";>
    <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..

CODE
// Get Query String
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

This post has been edited by 1dmf: Aug 12 2008, 09:11 AM
Go to the top of the page
 
+Quote Post
seo_bright
post Aug 12 2008, 09:07 AM
Post #7


HR 5
*****

Group: Active Members
Posts: 290
Joined: 8-June 05
User's local time:
Feb 9 2010, 04:07 PM
Member No.: 7,688



Sorry to tell you regarding the language. I use Javascript and ASP alone. I am unable to do so using the following:

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>
Go to the top of the page
 
+Quote Post
1dmf
post Aug 12 2008, 09:19 AM
Post #8


Keep Asking, Keep Questioning, Keep Learning
*******

Group: Active Members
Posts: 1,950
Joined: 24-May 07
User's local time:
Feb 9 2010, 08:07 PM
From: Worthing - England
Member No.: 17,339



the correct html is
CODE
selected="selected"
but that's semantics, what you have should work although in ASP , do you use single equals? if i'm comparing in JS or PERL I use
CODE
if var == 'value'
I guess ASP is like VBA anyways, youre using the right concept, so it must be an ASP syntax issue, and ASP isn't realy my bag.

I'll have a quick search after my meeting, but I think someone with ASP skills needs to help

Go to the top of the page
 
+Quote Post
1dmf
post Aug 12 2008, 10:03 AM
Post #9


Keep Asking, Keep Questioning, Keep Learning
*******

Group: Active Members
Posts: 1,950
Joined: 24-May 07
User's local time:
Feb 9 2010, 08:07 PM
From: Worthing - England
Member No.: 17,339



Well looking at other code they have something like this..

CODE
<% if "P"=Request.Form.Item("text1")  then response.write "selected"%>
any help?

you might also need to trim the var...
CODE
Client=Request.Form.Item("text1")
<option value="P" <% if trim(Client) = "P" then response.write "selected"%>>Products</option>

Go to the top of the page
 
+Quote Post
seo_bright
post Aug 13 2008, 02:19 AM
Post #10


HR 5
*****

Group: Active Members
Posts: 290
Joined: 8-June 05
User's local time:
Feb 9 2010, 04:07 PM
Member No.: 7,688



Thanks 1dmf. You gave me a good idea, I worked on it and was able to fetch the selected value. Thanks for your effort in giving the clues for the code. You have really driven me in the right direction.
Go to the top of the page
 
+Quote Post
1dmf
post Aug 13 2008, 03:29 AM
Post #11


Keep Asking, Keep Questioning, Keep Learning
*******

Group: Active Members
Posts: 1,950
Joined: 24-May 07
User's local time:
Feb 9 2010, 08:07 PM
From: Worthing - England
Member No.: 17,339



no probs, sorry we went round the houses, i have only dabled in a tiny bit of ASP when the occasion called for it, so definately a cases of the blind leading the blind on this one (IMG:style_emoticons/default/lol.gif)

Glad you could work it out (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
 
+Quote Post

  
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



This forum is sponsored by High Rankings, a Boston SEO Agency
- Lo-Fi Version Time is now: 9th February 2010 - 03:07 PM