Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > RocketCake
Combo Box

emvie468
Registered User
Quote
2020-10-12 19:03:58

I have a Combo Box on my webform. I am trying to code it so that the choice entered is retained, if correct, when the form returns other errors. Internet searches suggest I need to do this in the Value of the Combo Box from the Properties Pane in RocketCake. This I understand, however the code needs to be inserted between the <option> tags. The searches tell me the code is this (or other versions of this) :

<?php echo $Month =='December'?'selected':' ';?>

(where in my form, December is one of the choices for the Combo Box called 'Month', that can be chosen)

putting this in the Value (Properties pane) results in this:

<option value="<?php echo $Month =='December'?'selected':' ';?">December</option>

however, the code actually needs to be after the "" of value= and before the >December</option>. in other words, I want it to look like this:

<option value="December" <?php if ($Month == "December") { echo " selected"; }?>>December</option>

How can I get code to be inserted between <option value="..." and >....</option>?

Or is there another way to retain the drop-down choice selected when, if correct, stays there when form returns with other errors.


emvie468
Registered User
Quote
2020-10-12 21:05:20

Sorry, used two different versions of the code: So to be more clear (hopefully )

If I am trying to use:

<?php echo $Month =='December'?'selected':' ';?>
.
.
.
I would want it to look like this:

<option value="December" <?php echo $Month =='December'?'selected':' ';?>>December</option>


niko
Moderator
Quote
2020-10-13 08:01:05

Uh, I'm not sure you can do this in RocketCake by using the ComboBox element. Unfortunately, you probably need to use a Code element and paste the full code for the full combobox in there.
But if anyone else has an idea, maybe I just didn't get it right.


emvie468
Registered User
Quote
2020-10-18 22:20:41

Niko:

Thank you. This worked.

Next problem.... is redirecting the form. I will post a new thread so it can be searched if necessary.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact