if else statment

Results 1 to 4 of 4

Thread: if else statment

  1. #1
    Join Date
    Dec 1969
    Posts
    147

    Default if else statment

    hi, i have a listbox that have the the option surname, company.<BR>when the user selected surname and click on the submit button,<BR>it will be link to surname.asp while if the company is clicked, a link to company.asp. how do i use asp to do this?<BR><BR>

  2. #2
    Lars Wallin Guest

    Default RE: if else statment

    Hi Karen!<BR><BR>I am not 100% sure if i understood you correctly.<BR>You have 1 listbox with 2 options right?<BR><BR>This is my sollution anyway....<BR>this dosent use ASP, just plain old client side<BR>JavaScript.<BR><BR>// ---- Function to be put in the head of your html -------<BR><BR>function loadUrl(pageUrl)<BR>{<BR> var url = "filePath/" + pageUrl;<BR> document.location.href = url;<BR>}<BR><BR>// --------------------------------------------------------<BR><BR>This is your listbox code...<BR><BR>&#060;FORM NAME="formname" METHOD=POST"><BR>&#060;SELECT NAME="listbox"><BR>&#060;OPTION VALUE="company.asp">Company<BR> &#060;OPTION VALUE="surname.asp">Surname<BR>&#060;/SELECT><BR>&#060;INPUT TYPE="button" VALUE="Submit" onClick="loadUrl(document.formname.listbox.options[listbox.selectedIndex].value)"><BR>&#060;/FORM><BR><BR>This will do the trick........<BR><BR>You can also use this approach when populating<BR>listboxes dynamicly using ASP.<BR><BR>Have a good one!<BR><BR>Best regards<BR>Lars

  3. #3
    Join Date
    Dec 1969
    Posts
    147

    Default RE: if else statment

    that&#039s a kewl one, thanks:)<BR><BR>i follow your instructions and the script is:<BR><BR>&#060;html><BR><BR>&#060;head><BR>// ---- Function to be put in the head of your html -------<BR><BR>function loadUrl(pageUrl)<BR>{<BR>var url = "filePath/" + pageUrl;<BR>document.location.href = url;<BR>}<BR><BR>// --------------------------------------------------------<BR>&#060;/head><BR><BR>&#060;body background="bg2.gif"><BR><BR>&#060;form action="formname.asp" method="GET"><BR> <BR>&#060;SELECT NAME="listbox"><BR>&#060;OPTION VALUE="rock.asp">Company<BR>&#060;OPTION VALUE="rock1.asp">Surname<BR>&#060;/SELECT><BR><BR><BR>: &#060;input NAME="sc" MaxLength="23" size="23">&#060;/p><BR> &#060;div align="center">&#060;center>&#060;p>&#060;input TYPE="checkbox" NAME="ExactSearch" CHECKED>Exact Search&#060;/p><BR> &#060;/center>&#060;/div>&#060;a align="center">&#060;div align="center">&#060;center>&#060;p>*NOTE IF EXACT SEARCH IS NOT CHECKED <BR> YOU CAN USE %% AS WILDCARD&#060;/p>&#060;/center>&#060;/div>&#060;div align="center">&#060;center>&#060;p><BR><BR> &#060;INPUT TYPE="button" VALUE="Submit" onClick="loadUrl(document.formname.listbox.options[listbox.selectedIndex].value)">&nbsp;&#060;input type="reset" value="Clear ">&#060;/p><BR> &#060;/center>&#060;/div>&#060;/a><BR>&#060;/form><BR><BR>&#060;ul><BR> &#060;a HREF="Page1.ASP">&#060;p align="center">Home&#060;/a> &#060;a HREF="thundercat.ASP">Go To<BR> Custloc1:Table&#060;/a> &#060;a HREF="thunderbird.ASP">Go To Custove1:Table&#060;/a> &#060;a href="alumninetwork.asp">Go To Alumninetwork:Table &#060;/p><BR>&#060;/ul><BR>&#060;/a><BR>&#060;/body><BR>&#060;/html><BR><BR>when i run the page the commands in the header was display in my page. have i left out something?<BR><BR>thanks <BR><BR>

  4. #4
    Join Date
    Dec 1969
    Posts
    173

    Default RE: if else statment

    Sorry for not responding right away....<BR><BR>You have forgot to enclose the javascript function within:<BR>&#060;SCRIPT LANGUAGE="JavaScript"><BR><BR>//The script goes here<BR><BR>&#060;/SCRIPT><BR><BR>Good luck!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •