Jump to content

Need help: Automatic request system


Recommended Posts

Hi guys, so i've been working on this idea for quite a while now.. the only thing is.. i'm not exactly sure how to do it.. i want to make a automatic request system where you can request phone repair service trough the company website. something like: (DROPDOWN BOX) iPhone(selected) Samsung Nokia Sony Ericsson HTC ( DROPDOWNBOX which will react on first choice, like when i select iPhone something like this should come)iPhone 3(G)SiPhone 4iPhone 4 SiPhone 5 and then ofcourse the 3rd dropdown box where you will be selecting the problem(DROPDOWN BOX)Screen brokenButton doesnt workPhone wont chargeWater damagePhone wont go onSoftware issue and then the selected items gotta be saved in a database or something.. not exactly sure how i'm gonna do that.. (ofcourse there will be more info required to request a repair, like name and adress and all that.. but for now i just wat the dropdown boxes working) Soooooo.... anyways i've made an array with php before.. but i don't know exactly how to make them in combination with if//else like if iphone selected, include.... the other select.. here's what i made so far

<html><body>  <?php	$devices = array('iphone' => 'iPhone',				 'samsung' => 'Samsung',				 'nokia' => 'Nokia',				 'sonyericsson' => 'Sonyericsson',				 'htc' => 'HTC',);echo '<form method="post">';  echo '<select>';	foreach($devices AS $key => $value)			  echo '<option value="'. $key .'">'. $value .'</option>';	 echo '</select>';	echo '<input type="submit" value="Submit">';  echo '</form>';  ?></body></html>

If someone could help me i would really appriciate it, Thanks guys! Edit: I've tried something with buttons aswell... in combination with javascript.. didn't work out so well

 <!DOCTYPE html><html><head><script>function iphonebtn()	  /*The iPhone Buttons*/{document.getElementById("demo").innerHTML= "iPhone";var element = document.createElement("button");document.getElementById("apple").appendChild(element);var element2 = document.createElement("button");document.getElementById("apple").appendChild(element2);var element3 = document.createElement("button");document.getElementById("apple").appendChild(element3);document.getElementById("apple").getElementsByTagName("button")[1].innerHTML="iPhone 5";document.getElementById("apple").getElementsByTagName("button")[2].innerHTML="iPhone 4";document.getElementById("apple").getElementsByTagName("button")[3].innerHTML="iPhone 4s";		/*document.getElementById("apple").onclick = function(){ alert ("please choose problem")};*/};/*The Samsung Buttons*/function samsungbtn(){document.getElementById("demo2").innerHTML= "Samsung";var element4 = document.createElement("button");document.getElementById("samsung").appendChild(element4);var element5 = document.createElement("button");document.getElementById("samsung").appendChild(element5);var element6 = document.createElement("button");document.getElementById("samsung").appendChild(element6);document.getElementById("samsung").getElementsByTagName("button")[1].innerHTML="Galaxy SII";document.getElementById("samsung").getElementsByTagName("button")[2].innerHTML="Galaxy SIII";document.getElementById("samsung").getElementsByTagName("button")[3].innerHTML="Galaxy S Advance";		/*document.getElementById("samsung").onclick = function(){ alert ("please choose problem")};*/		};		/*The HTC Buttons*/	  function htcbtn(){		document.getElementById("demo4").innerHTML= "HTC";var element10 = document.createElement("button");document.getElementById("htc").appendChild(element10);var element11 = document.createElement("button");document.getElementById("htc").appendChild(element11);  var element12 = document.createElement("button");document.getElementById("htc").appendChild(element12);document.getElementById("htc").getElementsByTagName("button")[1].innerHTML="HTC one X";document.getElementById("htc").getElementsByTagName("button")[2].innerHTML="HTC one V";document.getElementById("htc").getElementsByTagName("button")[3].innerHTML="HTC one S";		/*document.getElementById("htc").onclick = function(){ alert ("please choose problem")};*/};	  /*The defect Buttons*/	  function defectbtn(){document.getElementById("demo3").innerHTML= "Problem";var element7 = document.createElement("button");document.getElementById("glass").appendChild(element7);var element8 = document.createElement("button");document.getElementById("glass").appendChild(element8);  var element9 = document.createElement("button");document.getElementById("glass").appendChild(element9);document.getElementById("glass").getElementsByTagName("button")[1].innerHTML="Water Damage";document.getElementById("glass").getElementsByTagName("button")[2].innerHTML="Phone wont Charge";document.getElementById("glass").getElementsByTagName("button")[3].innerHTML="Button doesn't work";	  };</script></head><body>  <font face="arial" size="4" color="blue"> Kies uw telefoon </font><div id="apple"><button id="demo" type="button" onclick="iphonebtn(),defectbtn(),this.disabled = 'disabled';"> iPhone </button></div><br /><div id="samsung"><button id="demo2" type="button" onclick="samsungbtn(),defectbtn(),this.disabled = 'disabled';"> Samsung </button></div><br />	<div id="htc"><button id="demo4" type="button" onclick="htcbtn(),defectbtn(),this.disabled = 'disabled';"> HTC </button></div><br />	 <div id="glass"><button id="demo3" type="button" onclick="defectbtn(),this.disabled = 'disabled';"> Problem </button></div><br />	<h1>Reparatie aanvragen</h1>  <p></p>  <form name='registration' onSubmit="return formValidation();">  <ul>  <li><label for="userid">ID (indien bekend)</label></li>  <li><input type="text" name="ID" size="12" /></li>  <li><label for="username">Voornaam:</label></li>  <li><input type="text" name="username" size="50" /></li>  <li><label for="address">Adres:</label></li>  <li><input type="text" name="address" size="50" /></li>  <li><label for="country">Land:</label></li>  <li><select name="country">  <option selected="" value="Default">(Selecteer een Land)</option>  <option value="AF">Nederland</option>  <option value="AD">Belgiƫ</option>  </select></li>  <li><label for="zip">Postcode:</label></li>  <li><input type="text" name="zip" /></li>  <li><label for="email">Email:</label></li>  <li><input type="text" name="email" size="50" /></li>  <li><label>Language:</label></li>	<li><label for="desc">Bijzonderheden:</label></li>  <li><textarea name="desc" id="desc"></textarea></li>  <li><input type="submit" name="submit" value="Submit" /></li>  </ul>  </form></body></html>

Edited by RmonDr
Link to comment
Share on other sites

If you want the dropdowns to get updated without the page reloading then you use Javascript for that. You can use PHP to write out the arrays in Javascript if those are coming from a database or something. There should be a ton of examples online about using Javascript to change select elements when you choose a value. I would probably have an array that lists all of the values they can choose in a dropdown, and the value for each array element would be another array that contains all of the options to put in the next dropdown when that value is selected. So one array per dropdown that lists the possible values for that dropdown and options for the next dropdown.

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...