How to remotely select a drop down option ?

Ron 15 Jun, 2014
Hello,
I have tried to find a solution on the net but could not find. I hope I could find help here.
<select id="equipment" name="equipment" required="true" style="font-family:Verdana, Geneva, sans-serif; width:480px; font-size:20px; border:1px solid #999;" onChange="change_selection();">

<option value="" selected="selected" >select one</option>
<option value="1">Hair</option>
<option value="2">Skin</option>
<option value="3">Bones</option>
<option value="4">Blood</option>
<option value="5">Heart</option>
</select>



I have a above form I would like to make a selection of the options by a remote link.
Example :

Link 1: <a href="http://xyz.com/form A">Hair</a>
Link 2: <a href="http://xyz.com/form A">Skin</a>
Link 3: <a href="http://xyz.com/form A">Bones</a>
Link 4: <a href="http://xyz.com/form A">Blood</a>
Link 5: <a href="http://xyz.com/form A">Heart</a>


When the page with the above form loads initiated by any of the above links the select box should be selected with the option as per the link. But the selection should take place when the page has loaded.

Please help.

Thanks

Ronn
GreyHead 15 Jun, 2014
HI Ronn,

<a href="http://xyz.com/form_A?equipment=1">Hair</a>


Bob
Ron 15 Jun, 2014
Thanks for the quick reply bob. But I get a form does not exist error when I add that value. I am thinking of using this field in the drop down value:
< ?php echo $_POST['equipment']; ? >
It works. but I want to add a delay of about 5 seconds after page load. How can I do that ?

Thanks Again

Ron
GreyHead 15 Jun, 2014
Hi Ronn,

If the link doesn't work then you have bad URL in the example you posted :-(

The full version would be something like this:
href='http://xyz.com/index.php?option=com_chronoforms&chronoform=form_A&equipment=2'
Note that you can't have a space in a form name so 'Form A' won't work.

Bob
Ron 15 Jun, 2014
Thanks bob it works.. But I have a problem. When a selection is made in the form a javascript triggers a popup window giving details about the equipment. This does not happen with this link as the selection is made before the page loads completely.

Is there a way I can make this link work after the page has loaded ?

Thanks for all the support.

Ron
GreyHead 15 Jun, 2014
Hi Ronn,

Add a JavaScript snippet that runs on page load and checks the value of the select drop-down. If it finds a setting then it triggers the popup.

Bob
Ron 15 Jun, 2014
Thanks for all the support bob,

I tried various javascripts to delay the <div> display. But I failed. Either the delay works or the selection works but not both together.
	function changeContent() {
			var last_div = document.getElementById('last_div');
			
			var html = "<p><select id='equipment' name='equipment' required='true' style='font-family:Verdana, Geneva, sans-serif; width:480px; font-size:20px; border:1px solid #999;' onChange='change_selection();'><option value='' selected='selected' >select one</option><option value='1'>Hair</option><option value='2'>Skin</option><option value='3'>Bones</option><option value='4'>Blood</option><option value='5'>Heart</option></select></p>";
			
			last_div.innerHTML = html;
		}
		
		function init() {
			setTimeout('changeContent()', 5000);
		}
		
		// call changeContent 5 seconds after the page loads
		window.onload = init;

I hope you have a suggestion.

thanks anyway

Ron
This topic is locked and no more replies can be posted.