Update Select via Query String

More
12 years 1 week ago #24959 by igcorreia
Hello,
I have this link, this is a REGULAR form submission in FC Front end:
Code:
/index.php?option=com_flexicontent&view=items&layout=form&typeid=1&Itemid=1?carselected=toyota
I have created a SELECT FC FIELD that list a few cars, this list is present in FC Front End Submission View:
Code:
<select id="cars" class=" required" name="cars"> <option selected="selected" value="">Please Select</option> <option value="1">Toyota</option> <option value="2">Mercedes</option> <option value="3">Bmw</option> </select>
I want to _GET the value from the query string:
Code:
carselected=toyota
And set the option Toyota as default:
Code:
<select id="cars" class=" required" name="cars"> <option value="" >Please Select</option> <option selected="selected" value="1">Toyota</option> <option value="2">Mercedes</option> <option value="3">Bmw</option> </select>
Can anyone help? This is awesome but I don't know where to start.

It could be in the FC SELECT PLUGIN or in the form view ether way I don't know more than this.

Please Log in or Create an account to join the conversation.

More
12 years 1 week ago #25057 by ggppdk
You could put some PHP code in any PHP file e.g. your joomla template, that adds some js JQuery code to use URL variable to set the required field:

But you must pass the id of the car instead of the name:

/index.php?option=com_flexicontent&view=items&layout=form&typeid=1&Itemid=1?carselected=4

(NOTE: you convert toyota to 4, but you would need a db query)
Code:
<?php $document = & JFactory::getDocument(); $option = JRequest::getVar('option'); $view = JRequest::getVar('option'); $layout = JRequest::getVar('layout'); $carselected = JRequest::getVar('carselected'); if ($option=='com_flexicontent' && $view='items' && $layout=='form' && $carselected) { $js = " window.addEvent('domready', function() { $('cars').val('".$carselected."'); } "; $document->addScriptDeclaration($js); } ?>



Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.249 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline