javascript - How to pass parameters to a URL from a select form? -
i want pass values select form url in order connect external website using iframe solutions.
i'm new .php & javascript. please me out.
this form created data users pass specific url.
<form action="selectcourier.php" method="get"> <h1>select courier service</h1> <select> <option value="select">select courier service</option> <option value="1">dtdc</option> <option value="2">afl</option> <option value="3">bluedart</option> </select> consignment number: <input type="text" name="cnum"><br> <center><input type="submit"></center> </form>
selectcourier.php
<body> <form><center><h3><a href="http://dtdc.com/tracking/tracking_results.asp?action=track&sec=tr&ctlactiveval=1&ttype=awb_no&strcnno=h60874238&ges=n&trktype2=awb_no&strcnno2=<?php echo $_get["cnum"]; ?>" target="ifrm"> confirm </a><h3></center>
<iframe id="ifrm" width=300 height=300 seamless src="http://example.com/"> </body>
my question:
hope have understood i'm trying give all courier tracking service right website using iframe. here i'm unable differentiate appropriate urls different types of courier service pass value (cnum) , open web link in iframe.
i have urls of courier services.
now how can differentiate them pick appropriate url when courier service selected user?
kindly me, please. thanks.
since want load url iframe based on selection, go this. basic explanation can found in comments:
<html lang="en"> <head> <script type="text/javascript"> // set global variables var serviceselect; var connumberelement; // wait page loaded document.addeventlistener('domcontentloaded', function() { // required elements serviceselect = document.getelementbyid("courierservice"); connumberelement = document.getelementbyid("cnum"); }); function loadwebsite(){ // iframe var ifrm = document.getelementbyid("ifrm"); // consignment number var connumber = connumberelement.value; // courier service var servicevalue = serviceselect.value; // make sure correct service selected if(servicevalue == "1"){ // dtdc selected ifrm.src = "http://dtdc.com/tracking/tracking_results.asp?action=track&sec=tr&ctlactiveval=1&ttype=awb_no&strcnno=" + connumber + "&ges=n&trktype2=awb_no&strcnno2=" + connumber; } else if(servicevalue == "2"){ // afl selected ifrm.src = ""; // add correct url here. take example above on how it. } else if(servicevalue == "3"){ // bluedart selected ifrm.src = ""; // add correct url here. take example above on how it. } else { alert("you have select correct courier service"); } } </script> </head> <body> <h1>select courier service</h1> <select id="courierservice"> <option value="select">select courier service</option> <option value="1">dtdc</option> <option value="2">afl</option> <option value="3">bluedart</option> </select> consignment number: <input type="text" id="cnum"><br> <input type="button" onclick="loadwebsite();" value="confirm" /> <iframe id="ifrm" width=300 height=300 seamless src="http://example.com/"> </body> </html>
Comments
Post a Comment