Jump to content

URL STRING QUERY


user4fun

Recommended Posts

URL String Query --------------------------------------------------------------------------------I believe what i am trying to do is called url stirng query. Anyways,I have an html page, it contains javascript (text) with in javascript afew equations are made after onclick "button"I really need for the results to show up i a different pagePResults.htm (in the body of the page)so really i trying to figure out how to send the values from Info.html to PResults.htmlplease please please help me,

Link to comment
Share on other sites

Hi,The JS function will retrive the values that you pass using the query string<html><script type="text/javascript">var qsParm = new Array();function qs() {var query = window.location.search.substring(1);var parms = query.split('&');for (var i=0; i<parms.length; i++) { var pos = parms.indexOf('='); if (pos > 0) { var key = parms.substring(0,pos); var val = parms.substring(pos+1); qsParm[key] = val; document.write(qsParm[key]) document.write("<br />") } }}</script></head><body onload="qs()"></html>HTH

Link to comment
Share on other sites

Where would i put the code that you have given methis is what i have so far.<code><html><head><script language="JavaScript">function myfunction() {//window.open("http://www.odoc.us/results.htm")var Sales = document.cal.Sales.valuevar Traffic = document.cal.Traffic.valuevar ProfitPerCust = document.cal.APPC.valuevar ErrorMess = "An Error has occured. Please make sure that all values are corect and the sales value is smaller than the number of traffic"var Message1 = "You have an EXTREMELY LOW"var Message2 = "You have a VER LOW"var Message3 = "You have a fairly low"var Message4 = "4444"var Message5 = "5555"var Message6 = "66666"var MessageA = "Gained Customers"var MessageB = "Lost Customers"var MessageC = "Profit Earned"var MessageD = "Lost Protential Profit"var SalesPercent = Sales / Traffic * 100var MissTraffic = 100 - SalesPercent//OUT OF 100 CUSTOMER INFOGainedCustomers = SalesPercentLostCustomers = MissTrafficProfitEarned = SalesPercent * ProfitPerCustLostPotentialProfit = LostCustomers * ProfitPerCustif (SalesPercent <= 10) { document.write(Message1 + " " + Math.round(SalesPercent) + "%" + " " + "Sales Percentage" + "<br />"); document.write ("<br />") document.write("your business analysis based on every 100 customers." + "<br />") ; document.write(MessageA + " " + "=" + " " + Math.round(GainedCustomers) + "<br />") ; document.write(MessageB + " " + "=" + " " + Math.round(LostCustomers) + "<br />"); document.write(MessageC + " " + "=" + " " + Math.round(ProfitEarned) + "$" +"<br />"); document.write(MessageD + " " + "=" + " " + "$" + Math.round(LostPotentialProfit) +"<br />"); } else if (SalesPercent > 10 && SalesPercent <= 20) { document.write("under 10") } else if (SalesPercent >=21 && SalesPercent <= 35) { document.write("netween 10 and 59") } else if (SalesPercent >=36 && SalesPercent <= 49) { document.write("between 36 nd 49") } else if (SalesPercent >=50 && SalesPercent <= 99) { document.write("Between 50 and 99") } else if (SalesPercent == 100) { document.write("???") } else { document.write(ErrorMess) } } </script></head><body><form name="FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript"><table border="0" id="table1" width="556"><tr> <td width="550"><font size="2">Enter your information based on a 24 business period.</font></td> </tr> </table> <table border="0" id="table2" width="555"><tr> <td width="50"><font size="2">Sales</font></td> <td> <!--webbot bot="Validation" s-data-type="Number" s-number-separators=",." b-value-required="TRUE" s-validation-constraint="Greater than or equal to" s-validation-value="0" --><input type = "text" name="Sales" size="10" value = ""></td></tr><tr> <td width="50"><font size="2">Traffic</font></td> <td> <!--webbot bot="Validation" b-value-required="TRUE" s-validation-constraint="Greater than or equal to" s-validation-value="0" --><input type = "text" name="Traffic" size="10" value = ""></td></tr><tr> <td width="50"><font size="2">AP/C</font></td> <td> <!--webbot bot="Validation" b-value-required="TRUE" s-validation-constraint="Greater than or equal to" s-validation-value="0" --><input type = "text" name="APPC" size="10" value = ""><i><font size="1">Average Profit Per Customer</font></i></td></tr><tr> <td width="84"><input type ="button" value="Calculate" onclick = "myfunction()" ></td> </tr> </table> </form></body></html></code>

Link to comment
Share on other sites

I wanted to send these varvar Sales var Traffic var ProfitPerCust var SalesPercent var MissTraffic GainedCustomers = SalesPercentLostCustomers = MissTrafficProfitEarned = SalesPercent * ProfitPerCustLostPotentialProfit = LostCustomers * ProfitPerCustIn a way i would like to send the results of the If statments. If i cannot do that then i guess i can rewrite them in the presults.html page correct.

Link to comment
Share on other sites

Well, In general the URL query string is used to pass few values to another page like this..www.domain.com?id=123&name=test(the variables are after the "?")fewer data can be sent, But if you have many values to be passed, the url will be too long, (not preferred)..I guess you too have many variables.I'm Not pretty sure, I could be wrong

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...