473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Passed a value in between html pages in url won't work for switch statement.

I'm using a hyperlink to pass a value from a home page to a search page. I'm using to values to identify and display only certain input/select boxs that relate to whatever unique search the user wants to use. I've gotten the value from "TYPE=VALUE" to display in my search page but now I'm wondering if it will work for my switch statement since none of my document.write statements are working.

Home Page links:

Expand|Select|Wrap|Line Numbers
  1. <BODY>                                            
  2. <FORM NAME="HOMEPAGE" ID="HOMEPAGE" METHOD="POST">
  3.  
  4. <B>SEARCH FOR A CIR:</B> <BR />                             
  5.    <A HREF="HTTPS://****.DSS.STATE.MO.US/YCRS?TYPE=REGION"> 
  6.    <LI> SEARCH BY REGION </LI>                              
  7.    <A HREF="HTTPS://****.DSS.STATE.MO.US/YCRS?TYPE=SUBMIT"> 
  8.    <LI> SEARCH BY SUBMITTER</LI>                            
  9.    <A HREF="HTTPS://****.DSS.STATE.MO.US/YCRS?TYPE=STUDENT">
  10.    <LI> SEARCH BY STUDENT ID</LI>                           
  11.    <A HREF="HTTPS://****.DSS.STATE.MO.US/YCRS?TYPE=DATE">   
  12.    <LI> SEARCH BY DATE</LI> <BR/>
  13. </FORM>
  14. </BODY>
  15.  
Search Page:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <head>  
  3. <script>
  4. function getparams(){                                                   
  5.  var idx=document.URL.indexOf('?');                                     
  6.  var params = new Array();                                              
  7.    if (idx != -1) {                                                     
  8. var pairs=document.URL.substring(idx+1, document.URL.length).split('&');
  9.     for (var i=0; i<pairs.length; i++)  {                               
  10.     nameVal = pairs[i].split('=');                                      
  11.     params[nameVal[0]] = nameVal[1];                                    
  12.    }                                                         }                                                           return params;                                                     }                                                            params = getparams();                                                
  13. </script>                                                  </head> 
  14.  
  15. <body>                                                     <form name="searchfunction" id="searchfunction" method="get">    
  16.  
  17. <input type=hidden name="srchTYPE"  id="srchTYPE">               
  18. <script type="text/javascript">                                  
  19.  
  20. var search = document.searchfunction.srchTYPE.value              
  21.  
  22. switch(search)                                                   
  23. {                                                          case REGION:                                                   
  24. document.write('<table border="0" width="100%">');               
  25. document.write('<tr>');                                          
  26. document.write('<td width="10%"><strong>REGION:</strong><br />');
  27. document.write('<select name="REGION" id="REGION"');
  28. etc. etc.
  29. break;
  30.  
  31.   case SUBMIT:                                                         
  32. document.write('<table border="0" width="100%">');                     
  33. document.write('<tr>');                                                
  34. document.write('<td width="10%"><strong>SUBMITTER ID:</strong><br />');
  35. etc. etc.
  36. break;
  37.  
  38.   case STUDENT:                                                         
  39. document.write('<table border="0" width="100%">');                      
  40. document.write('<tr>');                                                 
  41. document.write('<i>*If no student number is entered');                  
  42. document.write('the first student number from');                        
  43. document.write('the incident report will be displayed </i></tr>');      
  44. document.write('<tr><td width="10%"><strong>STUDENT #:</strong><br />');
  45. etc. etc.
  46. break;
  47.  
  48.   case DATE:                                                           
  49. document.write('<table border="0" width="100%">');                     
  50. document.write('<tr>');                                                
  51. document.write('<td width="10%"><strong>BEGIN SEARCH RANGE:</strong>');
  52. etc. etc.
  53. break;
  54. }
  55. </script>  
  56. </form>
  57.  
  58. <script language="JavaScript">                     
  59.     stype = unescape(params["TYPE"]);              
  60.     document.searchfunction.srchTYPE.value = stype;
  61. </script> 
  62. </body>                                         
  63.  
Any help would be much appreciated.
Nov 22 '10 #1
1 1232
RamananKalirajan
608 512MB
Implementing switch is possible. If you are using document.write it should be used during the page load. I tuned your code for local file and made some changes in the script. It seems working. Please have a look over your code and find where you can change.

Thanks and Regards
Ramanan Kalirajan
Nov 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Rob Tweed | last post by:
Two inter-related questions: If I'm in PHP page a.php, and I want to switch control to page b.php, the only mechanism I've come across is to use header('Location: someURL") ; This has two...
35
by: Thomas Matthews | last post by:
Hi, My son is writing a program to move a character. He is using the numbers on the keypad to indicate the direction of movement: 7 8 9 4 5 6 1 2 3 Each number has a direction except...
4
by: ruca | last post by:
Hi, How can I pass the values of some variables from page1.aspx to page2.aspx? I try to define some variables in page2 and then when I click a button in page1 it will fill that variables (in...
0
by: Ed | last post by:
I have a aspx site (intranet) that users can view sql data. They also use this site to register for things based on that data. My sql still works, but my forms (postbacks) do not why? Thanks..
12
by: Ant | last post by:
Hi, I need to return a value to a methods call from a switch statement nested in the method. How can this be done? int myMethod(int someValue) { switch (someValue) {
1
by: Berko | last post by:
I'm having problems with a switch statement that is wrapped in a foreach statement so that each index in an array is evaluated against the switch statement. The switch/case will then return some...
19
by: rdavis7408 | last post by:
Hello, I have four textboxes that the user enters the price per gallon paid at the pump, the mileage per gallon and I would like to then calculate the cost per gallon and use a switch statement to...
7
by: priyanka | last post by:
Hi there, I had a question. Is there any way of testing a string value in a switch statement. I have about 50 string values that can be in a string variable. I tried cheking them with the if...
5
by: Phuff | last post by:
Hey all, I need some direction help. I have a switch case statement that is seemingly my only option right now, but its too large and not easy to maintain the code. Here goes... I have part...
2
by: Phillip B Oldham | last post by:
What would be the optimal/pythonic way to subject an object to a number of tests (based on the object's attributes) and redirect program flow? Say I had the following: pets = {'name':...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.