Hello,
I need to have a dropdown-selection shown automaticly when accessing the form from a certain link.
How can I pass a query or variable to activare one certain selection?
I need the form to display its selected listing in the dropdown otherwise, but from one certain link I need to perform the task above.
Hope someone understands what I mean and can help here :-)
Regards,
Kurt
Norway
I need to have a dropdown-selection shown automaticly when accessing the form from a certain link.
How can I pass a query or variable to activare one certain selection?
I need the form to display its selected listing in the dropdown otherwise, but from one certain link I need to perform the task above.
Hope someone understands what I mean and can help here :-)
Regards,
Kurt
Norway
Hi Kurt,
You can add a variable to the URL like &var=XYZ and then get the variable value from the URL in the Form HTML with
You'd then need to use this value to add selected='selected' to the appropriate option in the drop-down. This is fairly easy to do with PHP.
Bob
You can add a variable to the URL like &var=XYZ and then get the variable value from the URL in the Form HTML with
<?php
$var = JRequest::getVar('var', '', 'get');
?>
You'd then need to use this value to add selected='selected' to the appropriate option in the drop-down. This is fairly easy to do with PHP.
Bob
Hey,
Thanks for trying to help a newbie here :-)
If you dont mind, please take a look here:
http://basale.frontal.no and click on the graphic with the picture of a key etc. This leads to the form, where the drop-down now shows the default "selected" value.
I need it to drop down to "leietager" when using the link on that frontpage-graphic.
Could you please try to instruct me on how you would have done this?
Regards,
Kurt
Norway
Thanks for trying to help a newbie here :-)
If you dont mind, please take a look here:
http://basale.frontal.no and click on the graphic with the picture of a key etc. This leads to the form, where the drop-down now shows the default "selected" value.
I need it to drop down to "leietager" when using the link on that frontpage-graphic.
Could you please try to instruct me on how you would have done this?
Regards,
Kurt
Norway
Hi Kurt,
First make the link from the graphic
Then change the drop-box code to be like this
Bob
First make the link from the graphic
http://basale.frontal.no/kontakt?henvendtype=leietager
Then change the drop-box code to be like this
<?php
$options_array = array('oppdragsgiver' => '', 'leietager' => '', 'annet' => '');
$henvendtype = JRequest::getString('henvendtype', '', 'get');
if ( $henvendtype ) {
$options_array[$henvendtype] = "selected='selected'";
}
?>
<select id="henvendtype" name="henvendtype" class="required">
<option value="">- Select -</option>
<option value="Oppdragsgiver" <?php echo $options_array['oppdragsgiver']; ?> >Oppdragsgiver</option>
<option value="Leietager" <?php echo $options_array['leietager']; ?> >Leietager</option>
<option value="Annet" <?php echo $options_array['annet']; ?> >Annet</option>
</select>
Bob
Wow! Thanks :-)
Thats what I call a nice feedback!
There must be something I have done wrong though, becouse the form isnt displayed when reaching it now.
This is the new code that I use:
Do you see whats wrong?
Thats what I call a nice feedback!
There must be something I have done wrong though, becouse the form isnt displayed when reaching it now.
This is the new code that I use:
<h1>Kontakt</h1>
<p><br></p>
<p>Vennligst fyll ut alle obligatoriske felter:</p>
<p> </p>
<?php
$options_array = array('oppdragsgiver' => '', 'leietager' => '', 'annet' => '');
$henvendtype = JRequest::getString('henvedntype', '', 'post');
if ( $henvendtype ) {
$options_array[$henvendtype] = "selected='selected'";
}
?>
<table width="510" border="0">
<tr>
<td>Jeg henvender meg som:</td>
<td colspan="3"><label for="henvendtype"></label>
<select id="henvendtype" name="henvendtype" class="required">
<option value="">- Select -</option>
<option value="Oppdragsgiver" <?php echo $options_array['oppdragsgiver']; ?> >Oppdragsgiver</option>
<option value="Leietager" <?php echo $options_array['leietager']; ?> >Leietager</option>
<option value="Annet" <?php echo $options_array['annet']; ?> >Annet</option>
</select></td>
</tr>
<tr>
<td>Firma: *</td>
<td colspan="3"><input name="firma" type="text" id="firma" size="35" title="Påkrevd" /></td>
</tr>
<tr>
<td>Adresse:</td>
<td colspan="3"><input name="adr" type="text" id="adr" size="35" /></td>
</tr>
<tr>
<td>Kontaktperson: *</td>
<td colspan="3"><input name="kontaktperson" type="text" id="kontaktperson" size="35" title="Påkrevd" /></td>
</tr>
<tr>
<td>Telefon: *</td>
<td colspan="3"><input name="tlf" type="text" id="tlf" size="35" title="Påkrevd" /></td>
</tr>
<tr>
<td>E-post: *</td>
<td colspan="3"><input name="epost" type="text" id="epost" size="35" title="Påkrevd" /></td>
</tr>
<tr>
<td valign="top">Henvendelsen gjelder:</td>
<td colspan="3"><textarea name="henvendelse" cols="38" rows="8" id="henvendelse"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td width="158" align="right"><input type="submit" name="send" id="send" value="Send" /></td>
<td width="69"> </td>
</tr>
</table>
Do you see whats wrong?
Hi Kurt,
There were two typos in this line in my code- 'henvendtype' mistyped and 'post' instead of 'get'
They don't explain why the form isn't showing on your site though. I copied the code that you posted into a new form and that shows up OK :-(
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
There were two typos in this line in my code- 'henvendtype' mistyped and 'post' instead of 'get'
$henvendtype = JRequest::getString('henvendtype', '', 'get');
(I'll go back and correct the original post).They don't explain why the form isn't showing on your site though. I copied the code that you posted into a new form and that shows up OK :-(
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
Hi Kurt,
Hmmm . . . I've never seen this before. The problem is with the spaces at the beginning of this line
The second space is OK but the first one looks like a normal space but isn't. If you look in a Hex editor it's actually the UTF 'C2 A0' non-breaking space and PHP chokes on it.
I guess that this is a feature of the HTML editor you are using as it appears a few other places in the document where there are spaces at the beginning of a line.
If you replace the one in the PHP with an 'ordinary' space then all should be well.
Bob
Hmmm . . . I've never seen this before. The problem is with the spaces at the beginning of this line
$options_array[$henvendtype] = "selected='selected'";
The second space is OK but the first one looks like a normal space but isn't. If you look in a Hex editor it's actually the UTF 'C2 A0' non-breaking space and PHP chokes on it.
I guess that this is a feature of the HTML editor you are using as it appears a few other places in the document where there are spaces at the beginning of a line.
If you replace the one in the PHP with an 'ordinary' space then all should be well.
Bob
This topic is locked and no more replies can be posted.