How to Modify XML File using Powershell - powershell

Hi Friends i want to modify some Text value in <Option Name="Activate">1</Option> to <Option Name="Activate">0</Option>. I am unable to locate node value <Option Name="Activate">1</Option> using powershell. below is the full code section in which i want to modify the Text. Please help.
<User Name="Richard">
<Option Name="Pass">b56e0b4ea4962283bee762525c2d490f</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback"></Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
Download XML File Here
So far i have tried Below Code but unable to complete. :(
$xml = New-Object XML
$XML.Load("D:\PSScript\BookStore.xml")
$xml.bookstore.Users.user |
Where-Object { ($_.Name -eq 'Richard')} |
Select-Object -Property Option
**Note : I want to use a condition here for example i want to change 1 Tag text value only for specific user, In short i want to modify text based on user id, Like where name = Richard change its <Option Name="Activate">1</Option> to <Option Name="Activate">0</Option> **
<BookStore>
<Settings>
<Item name="Admin port" type="numeric">88881</Item>
</Settings>
<Container>
<Containers Name="MasterVal">
<Option Name="Max Limit Allowed">0</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">0</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations>
<Authorization path="E:\BookMaster\RootFolder">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">0</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">0</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\reports">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\NT">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\WIN">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\Winsxs">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\SXS">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">1</Option>
</Authorization>
</Authorizations>
<SpeedLimits DlType="1" DlLimit="10" ServerDlLimitBypass="0" UlType="1" UlLimit="10" ServerUlLimitBypass="0">
<Download />
<Upload />
</SpeedLimits>
</Containers>
<Containers Name="DMPL(9990)-D">
<Option Name="Max Limit Allowed">0</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">0</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations>
<Authorization path="E:\BookMaster\RootFolder\MST">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">0</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">0</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\NT\Report_9990">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
</Authorizations>
<SpeedLimits DlType="1" DlLimit="10" ServerDlLimitBypass="0" UlType="1" UlLimit="10" ServerUlLimitBypass="0">
<Download />
<Upload />
</SpeedLimits>
</Containers>
</Container>
<Users>
<User Name="leonardo">
<Option Name="Pass">05538eb07b4dbf66b1da4ea9374ac8f5</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="repturet">
<Option Name="Pass">e076fc6c4c8a245beec106646719f738</Option>
<Option Name="Containers">
</Option>
<Option Name="Max Limit Allowed">0</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">0</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations>
<Authorization path="E:\BookMaster\RootFolder\MST\NT">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">0</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">0</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
</Authorizations>
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="0" UlType="0" UlLimit="10" ServerUlLimitBypass="0">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="Anuj">
<Option Name="Pass">270a8eaf5877a08bc69bdde947f8e8b6</Option>
<Option Name="Containers">DMPL(9990)-D</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="pallavi">
<Option Name="Pass">8d644bb6af9f1822de1d668d0ea6c36a</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="piyush">
<Option Name="Pass">db699a999e4a6c8bd867720850d3007c</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="Richard">
<Option Name="Pass">b56e0b4ea4962283bee762525c2d490f</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
</Users>
</BookStore>

Your main problem is you need to treat option elements as arrays. I copied your xml snippet to a file called test.xml and this code works (I'll explain how I parsed through your xml file at each step to show where Option is displaying as an array):
[xml] $info = Get-Content test.xml #Shorthand for New-Object..Load
#This command isn't necessary but is helpful when looking for an attribute
$info | Format-List *
#From above command saw that $info.User is the base document element
$info.User
#showed Attribute in Option
$info.User.Option
#displayed an array element with Attribute as the 5 (6th cause you start at 0) index
$info.User.Option[5]
#displayed Name and #text attributes with #text = 1
$info.User.Option[5].'#text' = "0"
#updated #text attribute to 0
From this you should be able to modify your script to work with the full xml file.
As your still having problems, a better solution would be to adjust your xml so you can access each user as a full object rather then parsing through attributes:
<User>
<name>Richard</name>
<pass>b56e0b4ea4962283bee762525c2d490f</pass>
<containers>MasterVal</containers>
<maxLimit>2</maxLimit>
<minLimit>0</minLimit>
<userLimit>0</userLimit>
<activate>1</activate>
<feedback></feedback>
<forceSsl>2</forceSsl>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0"
UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
Then you can access each user as $info.User.Richard and change each activate tags using $info.User.Richard.activate = 0. If you cannot do this you'll need to use foreach:
[xml] $info = Get-Content test.xml
foreach ($i in $info.BookStore.Users.User) {
if ($i.Name -eq "Richard") {
foreach ($e in $i.Option) {
if ($e.Name -eq "Activate") {
$e.'#text' = "0"
}
}
}
}
Then just write the xml back to the file. Note: Look at the use of select and select-xml if you want to simplify this later
Updated: with full answer given xml file

Related

how to add dynamic class name in thymeleaf in select option?

i submit with model to template
in template
i used th:each and in th:each i used select option
i want to dynamically add select's class name
"${cos_seq}" is int so i add 'abc'
<th:each="row:${Basket}">
<select class="'abc'+'${row.cos_seq}'"
th:value="${row.cos_seq}" style="float:left;margin-
right:5px ;width:45px;height:42px;" >
<option
class="qty-option" value="1" text="1"
style="width:20px">1</option>
<option
class="qty-option" value="2" text="2"
style="width:20px">2</option>
<option
class="qty-option" value="3" text="3"
style="width:20px">3</option>
<option
class="qty-option" value="4" text="4"
style="width:20px">4</option>
<option
class="qty-option" value="5" text="5"
style="width:20px">5</option>
<option
class="qty-option" value="6" text="6"
style="width:20px">6</option>
<option
class="qty-option" value="7" text="7"
style="width:20px">7</option>
<option
class="qty-option" value="8" text="8"
style="width:20px">8</option>
<option
class="qty-option" value="9" text="9"
style="width:20px">9</option>
<option
class="qty-option" value="10+" text="10+"
style="width:20px">10+</option>
</select>

Execute Intelij IDEA code format when committing

I would like to apply a code format action before I'm commiting.
Currently I have xml eclipse file that would define the format I would apply.
Since I have gradle and spotless I declared an action such as:
spotless {
enforceCheck false
java {
licenseHeaderFile "${rootDir}/LICENSE"
// licenseHeaderFile "${rootDir}/LICENSE"
eclipse().configFile("eclipse/formater.xml")
}
}
That is triggered by a shell script that is a git hook:
#!/bin/bash
set -e
toFormat="$(git --no-pager diff --name-status --cached | awk '$1 != "D" && $2 ~ /\.kts|\.java|\.kt/ { print $NF}')"
echo "Will format the files:"
echo $toFormat | tr " " "\n"
for fileToFormatPath in $eligibleToFormat
do
./gradlew spotlessApply -PspotlessIdeHook="$(pwd)/$fileToFormatPath"
git add $fileToFormatPath
done;
And so far it is working.
Now I would like to do it but directly using the declared IDEA xml formater such as:
<code_scheme name="formater" version="173">
<JavaCodeStyleSettings>
<option name="ANNOTATION_PARAMETER_WRAP" value="1" />
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="120" />
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="true" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="2" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="2" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="2" />
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="5=4" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="RESOURCE_LIST_WRAP" value="5" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
I don't find much idea on the internet, any suggestion ?

How do i always start a defined value in a select html element

I have predefined range values as options of a select element the ranges can be from any negative values to a predefined positive (I am using the select2 plugin).
For instance -12 to +12 at a defined increment say 0.25 in this case How do i get the option values to always start at 0.
<select id="form_exam:currentLenses:rCylinder" name="form[exam:currentLenses:rCylinder]" class="select-2 form-control select2-hidden-accessible" data-select2-id="form_exam:currentLenses:rCylinder" tabindex="-1" aria-hidden="true">
<option value="" data-select2-id="24">
</option>
<option value="-12.00" data-select2-id="115">-12.00</option>
<option value="-11.75" data-select2-id="116">-11.75</option>
<option value="-11.50" data-select2-id="117">-11.50</option>
<option value="-11.25" data-select2-id="118">-11.25</option>
<option value="-11.00" data-select2-id="119">-11.00</option>
<option value="-10.75" data-select2-id="120">-10.75</option>
<option value="-10.50" data-select2-id="121">-10.50</option>
<option value="-10.25" data-select2-id="122">-10.25</option>
<option value="-10.00" data-select2-id="123">-10.00</option>
<option value="-9.75" data-select2-id="124">-9.75</option>
<option value="-9.50" data-select2-id="125">-9.50</option>
<option value="-9.25" data-select2-id="126">-9.25</option>
<option value="-9.00" data-select2-id="127">-9.00</option>
<option value="-8.75" data-select2-id="128">-8.75</option>
<option value="-8.50" data-select2-id="129">-8.50</option>
<option value="-8.25" data-select2-id="130">-8.25</option>
<option value="-8.00" data-select2-id="131">-8.00</option>
<option value="-7.75" data-select2-id="132">-7.75</option>
<option value="-7.50" data-select2-id="133">-7.50</option>
<option value="-7.25" data-select2-id="134">-7.25</option>
<option value="-7.00" data-select2-id="135">-7.00</option>
<option value="-6.75" data-select2-id="136">-6.75</option>
<option value="-6.50" data-select2-id="137">-6.50</option>
<option value="-6.25" data-select2-id="138">-6.25</option>
<option value="-6.00" data-select2-id="139">-6.00</option>
<option value="-5.75" data-select2-id="140">-5.75</option>
<option value="-5.50" data-select2-id="141">-5.50</option>
<option value="-5.25" data-select2-id="142">-5.25</option>
<option value="-5.00" data-select2-id="143">-5.00</option>
<option value="-4.75" data-select2-id="144">-4.75</option>
<option value="-4.50" data-select2-id="145">-4.50</option>
<option value="-4.25" data-select2-id="146">-4.25</option>
<option value="-4.00" data-select2-id="147">-4.00</option>
<option value="-3.75" data-select2-id="148">-3.75</option>
<option value="-3.50" data-select2-id="149">-3.50</option>
<option value="-3.25" data-select2-id="150">-3.25</option>
<option value="-3.00" data-select2-id="151">-3.00</option>
<option value="-2.75" data-select2-id="152">-2.75</option>
<option value="-2.50" data-select2-id="153">-2.50</option>
<option value="-2.25" data-select2-id="154">-2.25</option>
<option value="-2.00" data-select2-id="155">-2.00</option>
<option value="-1.75" data-select2-id="156">-1.75</option>
<option value="-1.50" data-select2-id="157">-1.50</option>
<option value="-1.25" data-select2-id="158">-1.25</option>
<option value="-1.00" data-select2-id="159">-1.00</option>
<option value="-0.75" data-select2-id="160">-0.75</option>
<option value="-0.50" data-select2-id="161">-0.50</option>
<option value="-0.25" data-select2-id="162">-0.25</option>
<option value="0.00" data-select2-id="163">0.00</option>
<option value="+0.25" data-select2-id="164">+0.25</option>
<option value="+0.50" data-select2-id="165">+0.50</option>
<option value="+0.75" data-select2-id="166">+0.75</option>
<option value="+1.00" data-select2-id="167">+1.00</option>
<option value="+1.25" data-select2-id="168">+1.25</option>
<option value="+1.50" data-select2-id="169">+1.50</option>
<option value="+1.75" data-select2-id="170">+1.75</option>
<option value="+2.00" data-select2-id="171">+2.00</option>
<option value="+2.25" data-select2-id="172">+2.25</option>
<option value="+2.50" data-select2-id="173">+2.50</option>
<option value="+2.75" data-select2-id="174">+2.75</option>
<option value="+3.00" data-select2-id="175">+3.00</option>
<option value="+3.25" data-select2-id="176">+3.25</option>
<option value="+3.50" data-select2-id="177">+3.50</option>
<option value="+3.75" data-select2-id="178">+3.75</option>
<option value="+4.00" data-select2-id="179">+4.00</option>
<option value="+4.25" data-select2-id="180">+4.25</option>
<option value="+4.50" data-select2-id="181">+4.50</option>
<option value="+4.75" data-select2-id="182">+4.75</option>
<option value="+5.00" data-select2-id="183">+5.00</option>
<option value="+5.25" data-select2-id="184">+5.25</option>
<option value="+5.50" data-select2-id="185">+5.50</option>
<option value="+5.75" data-select2-id="186">+5.75</option>
<option value="+6.00" data-select2-id="187">+6.00</option>
<option value="+6.25" data-select2-id="188">+6.25</option>
<option value="+6.50" data-select2-id="189">+6.50</option>
<option value="+6.75" data-select2-id="190">+6.75</option>
<option value="+7.00" data-select2-id="191">+7.00</option>
<option value="+7.25" data-select2-id="192">+7.25</option>
<option value="+7.50" data-select2-id="193">+7.50</option>
<option value="+7.75" data-select2-id="194">+7.75</option>
<option value="+8.00" data-select2-id="195">+8.00</option>
<option value="+8.25" data-select2-id="196">+8.25</option>
<option value="+8.50" data-select2-id="197">+8.50</option>
<option value="+8.75" data-select2-id="198">+8.75</option>
<option value="+9.00" data-select2-id="199">+9.00</option>
<option value="+9.25" data-select2-id="200">+9.25</option>
<option value="+9.50" data-select2-id="201">+9.50</option>
<option value="+9.75" data-select2-id="202">+9.75</option>
<option value="+10.00" data-select2-id="203">+10.00</option>
<option value="+10.25" data-select2-id="204">+10.25</option>
<option value="+10.50" data-select2-id="205">+10.50</option>
<option value="+10.75" data-select2-id="206">+10.75</option>
<option value="+11.00" data-select2-id="207">+11.00</option>
<option value="+11.25" data-select2-id="208">+11.25</option>
<option value="+11.50" data-select2-id="209">+11.50</option>
<option value="+11.75" data-select2-id="210">+11.75</option>
<option value="+12.00" data-select2-id="211">+12.00</option>
</select>
The value 0 is actually significant so i can't just default to zero
Simply you can use selected attribute on the default option:
<option value="0.00" data-select2-id="163" selected>0.00</option>
Check this: https://jsfiddle.net/beaver71/hrj6mzga/

Where does a customer enter coupon code 2checkout?

I want to add coupons on my live site but before I do that I am testing the coupons on my sandbox. I have created coupons in the 2checkout admin area. According to the documentation, a customer enters the coupon code after being redirected to the 2checkout site. However, I only see the pop up but i don't see any area to enter coupon code.What gives?
<form class="form-horizontal form" action="<?php echo $action;?>" method="post">
<div class="panel panel-primary">
<div class="panel-heading"><strong>BILLING INFORMATION</strong></div>
<div class="panel-body">
<div class="form-group required">
<label class="col-md-2">Country</label>
<div class="col-md-10">
<select id="country" class="form-control" name="country" autocomplete="on" required="">
<option value="" class="ng-binding">- Choose Country -</option>
<option value="USA">United States</option>
<option value="GBR">United Kingdom</option>
<option value="CAN">Canada</option>
<option value="AUS">Australia</option>
<option disabled="" value="—">—</option>
<option value="ALA">Åland Islands</option>
<option value="AFG">Afghanistan</option>
<option value="ALB">Albania</option>
<option value="DZA">Algeria</option>
<option value="ASM">American Samoa</option>
<option value="AND">Andorra</option>
<option value="AGO">Angola</option>
<option value="AIA">Anguilla</option>
<option value="ATA">Antarctica</option>
<option value="ATG">Antigua and Barbuda</option>
<option value="ARG">Argentina</option>
<option value="ARM">Armenia</option>
<option value="ABW">Aruba</option>
<option value="AUS">Australia</option>
<option value="AUT">Austria</option>
<option value="AZE">Azerbaijan</option>
<option value="BHS">Bahamas</option>
<option value="BHR">Bahrain</option>
<option value="BGD">Bangladesh</option>
<option value="BRB">Barbados</option>
<option value="BLR">Belarus</option>
<option value="BEL">Belgium</option>
<option value="BLZ">Belize</option>
<option value="BEN">Benin</option>
<option value="BMU">Bermuda</option>
<option value="BTN">Bhutan</option>
<option value="BOL">Bolivia</option>
<option value="BES">Bonaire, Sint Eustatius and Saba</option>
<option value="BIH">Bosnia and Herzegovina</option>
<option value="BWA">Botswana</option>
<option value="BVT">Bouvet Island</option>
<option value="BRA">Brazil</option>
<option value="IOT">British Indian Ocean Territory</option>
<option value="BRN">Brunei Darussalam</option>
<option value="BGR">Bulgaria</option>
<option value="BFA">Burkina Faso</option>
<option value="BDI">Burundi</option>
<option value="KHM">Cambodia</option>
<option value="CMR">Cameroon</option>
<option value="CAN">Canada</option>
<option value="CPV">Cape Verde</option>
<option value="CYM">Cayman Islands</option>
<option value="CAF">Central African Republic</option>
<option value="TCD">Chad</option>
<option value="CHL">Chile</option>
<option value="CHN">China</option>
<option value="CXR">Christmas Island</option>
<option value="CCK">Cocos (Keeling) Islands</option>
<option value="COL">Colombia</option>
<option value="COM">Comoros</option>
<option value="COG">Congo</option>
<option value="COD">Congo, the Democratic Republic of the</option>
<option value="COK">Cook Islands</option>
<option value="CRI">Costa Rica</option>
<option value="CIV">Cote D'ivoire</option>
<option value="HRV">Croatia (Hrvatska)</option>
<option value="CYP">Cyprus</option>
<option value="CZE">Czech Republic</option>
<option value="DNK">Denmark</option>
<option value="DJI">Djibouti</option>
<option value="DMA">Dominica</option>
<option value="DOM">Dominican Republic</option>
<option value="ECU">Ecuador</option>
<option value="EGY">Egypt</option>
<option value="SLV">El Salvador</option>
<option value="GNQ">Equatorial Guinea</option>
<option value="ERI">Eritrea</option>
<option value="EST">Estonia</option>
<option value="ETH">Ethiopia</option>
<option value="FLK">Falkland Islands (Malvinas)</option>
<option value="FRO">Faroe Islands</option>
<option value="FJI">Fiji</option>
<option value="FIN">Finland</option>
<option value="FRA">France</option>
<option value="FXX">France, Metropolitan</option>
<option value="GUF">French Guiana</option>
<option value="PYF">French Polynesia</option>
<option value="ATF">French Southern Territories</option>
<option value="GAB">Gabon</option>
<option value="GMB">Gambia</option>
<option value="GEO">Georgia</option>
<option value="DEU">Germany</option>
<option value="GHA">Ghana</option>
<option value="GIB">Gibraltar</option>
<option value="GRC">Greece</option>
<option value="GRL">Greenland</option>
<option value="GRD">Grenada</option>
<option value="GLP">Guadeloupe</option>
<option value="GUM">Guam</option>
<option value="GTM">Guatemala</option>
<option value="GGY">Guernsey</option>
<option value="GIN">Guinea</option>
<option value="GNB">Guinea-Bissau</option>
<option value="GUY">Guyana</option>
<option value="HTI">Haiti</option>
<option value="HMD">Heard Island and Mcdonald Islands</option>
<option value="HND">Honduras</option>
<option value="HKG">Hong Kong</option>
<option value="HUN">Hungary</option>
<option value="ISL">Iceland</option>
<option value="IND">India</option>
<option value="IDN">Indonesia</option>
<option value="IRQ">Iraq</option>
<option value="IRL">Ireland</option>
<option value="IMN">Isle of Man</option>
<option value="ISR">Israel</option>
<option value="ITA">Italy</option>
<option value="JAM">Jamaica</option>
<option value="JPN">Japan</option>
<option value="JEY">Jersey</option>
<option value="JOR">Jordan</option>
<option value="KAZ">Kazakhstan</option>
<option value="KEN">Kenya</option>
<option value="KIR">Kiribati</option>
<option value="KOR">Korea, Republic of</option>
<option value="UNK">UNK</option>
<option value="KWT">Kuwait</option>
<option value="KGZ">Kyrgyzstan</option>
<option value="LAO">Lao People's Democratic Republic</option>
<option value="LVA">Latvia</option>
<option value="LBN">Lebanon</option>
<option value="LSO">Lesotho</option>
<option value="LBR">Liberia</option>
<option value="LBY">Libyan Arab Jamahiriya</option>
<option value="LIE">Liechtenstein</option>
<option value="LTU">Lithuania</option>
<option value="LUX">Luxembourg</option>
<option value="MAC">Macao</option>
<option value="MKD">Macedonia</option>
<option value="MDG">Madagascar</option>
<option value="MWI">Malawi</option>
<option value="MYS">Malaysia</option>
<option value="MDV">Maldives</option>
<option value="MLI">Mali</option>
<option value="MLT">Malta</option>
<option value="MHL">Marshall Islands</option>
<option value="MTQ">Martinique</option>
<option value="MRT">Mauritania</option>
<option value="MUS">Mauritius</option>
<option value="MYT">Mayotte</option>
<option value="MEX">Mexico</option>
<option value="FSM">Micronesia, Federated States of</option>
<option value="MDA">Moldova, Republic of</option>
<option value="MCO">Monaco</option>
<option value="MNG">Mongolia</option>
<option value="MNE">Montenegro</option>
<option value="MSR">Montserrat</option>
<option value="MAR">Morocco</option>
<option value="MOZ">Mozambique</option>
<option value="MMR">Myanmar</option>
<option value="NAM">Namibia</option>
<option value="NRU">Nauru</option>
<option value="NPL">Nepal</option>
<option value="NLD">Netherlands</option>
<option value="ANT">Netherlands Antilles</option>
<option value="NCL">New Caledonia</option>
<option value="NZL">New Zealand</option>
<option value="NIC">Nicaragua</option>
<option value="NER">Niger</option>
<option value="NGA">Nigeria</option>
<option value="NIU">Niue</option>
<option value="NFK">Norfolk Island</option>
<option value="MNP">Northern Mariana Islands</option>
<option value="NOR">Norway</option>
<option value="OMN">Oman</option>
<option value="PAK">Pakistan</option>
<option value="PLW">Palau</option>
<option value="PSE">Palestinian Territory, Occupied</option>
<option value="PAN">Panama</option>
<option value="PNG">Papua New Guinea</option>
<option value="PRY">Paraguay</option>
<option value="PER">Peru</option>
<option value="PHL">Philippines</option>
<option value="PCN">Pitcairn</option>
<option value="POL">Poland</option>
<option value="PRT">Portugal</option>
<option value="PRI">Puerto Rico</option>
<option value="QAT">Qatar</option>
<option value="REU">Reunion</option>
<option value="ROU">Romania</option>
<option value="RUS">Russian Federation</option>
<option value="RWA">Rwanda</option>
<option value="SHN">Saint Helena</option>
<option value="KNA">Saint Kitts and Nevis</option>
<option value="LCA">Saint Lucia</option>
<option value="SPM">Saint Pierre and Miquelon</option>
<option value="VCT">Saint Vincent and the Grenadines</option>
<option value="WSM">Samoa</option>
<option value="SMR">San Marino</option>
<option value="STP">Sao Tome and Principe</option>
<option value="SAU">Saudi Arabia</option>
<option value="SEN">Senegal</option>
<option value="SRB">Serbia</option>
<option value="SCG">Serbia and Montenegro</option>
<option value="SYC">Seychelles</option>
<option value="SLE">Sierra Leone</option>
<option value="SGP">Singapore</option>
<option value="SVK">Slovakia</option>
<option value="SVN">Slovenia</option>
<option value="SLB">Solomon Islands</option>
<option value="SOM">Somalia</option>
<option value="ZAF">South Africa</option>
<option value="SGS">South Georgia and the South Sandwich Islands</option>
<option value="ESP">Spain</option>
<option value="LKA">Sri Lanka</option>
<option value="SUR">Suriname</option>
<option value="SJM">Svalbard and Jan Mayen Islands</option>
<option value="SWZ">Swaziland</option>
<option value="SWE">Sweden</option>
<option value="CHE">Switzerland</option>
<option value="TWN">Taiwan</option>
<option value="TJK">Tajikistan</option>
<option value="TZA">Tanzania, United Republic of</option>
<option value="THA">Thailand</option>
<option value="TLS">Timor-Leste</option>
<option value="TGO">Togo</option>
<option value="TKL">Tokelau</option>
<option value="TON">Tonga</option>
<option value="TTO">Trinidad and Tobago</option>
<option value="TUN">Tunisia</option>
<option value="TUR">Turkey</option>
<option value="TKM">Turkmenistan</option>
<option value="TCA">Turks and Caicos Islands</option>
<option value="TUV">Tuvalu</option>
<option value="UGA">Uganda</option>
<option value="UKR">Ukraine</option>
<option value="ARE">United Arab Emirates</option>
<option value="GBR">United Kingdom</option>
<option value="USA">United States</option>
<option value="UMI">United States Minor Outlying Islands</option>
<option value="URY">Uruguay</option>
<option value="UZB">Uzbekistan</option>
<option value="VUT">Vanuatu</option>
<option value="VAT">Vatican City State (Holy See)</option>
<option value="VEN">Venezuela</option>
<option value="VNM">Viet Nam</option>
<option value="VGB">Virgin Islands, British</option>
<option value="VIR">Virgin Islands, U.S.</option>
<option value="WLF">Wallis and Futuna Islands</option>
<option value="ESH">Western Sahara</option>
<option value="YEM">Yemen</option>
<option value="YUG">Yugoslavia</option>
<option value="ZAR">Zaire</option>
<option value="ZMB">Zambia</option>
<option value="ZWE">Zimbabwe</option>
</select>
</div>
</div>
<div class="form-group required">
<label class="col-md-2">Full Name</label>
<div class="col-md-10">
<input class="form-control" id="card_holder_name" name="card_holder_name" type="text" placeholder="Full Name" required />
</div>
</div>
<div class="form-group required">
<label class="col-md-2">Address 1</label>
<div class="col-md-10">
<input class="form-control" id="street_address" name="street_address" type="text" placeholder="Address 1" required />
</div>
</div>
<div class="form-group">
<label class="col-md-2">Address 2</label>
<div class="col-md-10">
<input class="form-control" id="street_address2" name="street_address2" type="text" placeholder="Address 2"/>
</div>
</div>
<div class="form-group required">
<label class="col-md-2">City</label>
<div class="col-md-10">
<input class="form-control" id="city" name="city" type="text" placeholder="City" required />
</div>
</div>
<div class="form-group required">
<label class="col-md-2">State / Province</label>
<div class="col-md-10">
<input class="form-control" id="state" name="state" type="text" placeholder="State/Province" required />
</div>
</div>
<div class="form-group required">
<label class="col-md-2">Postal Code</label>
<div class="col-md-10">
<input class="form-control" id="zip" name="zip" type="text" placeholder="Postal Code" required />
</div>
</div>
<div class="form-group">
<label class="col-md-2">Phone</label>
<div class="col-md-10">
<input class="form-control" id="phone" name="phone" type="text" placeholder="Phone" required />
</div>
</div><!--form group-->
<div class="form-group required">
<label class="col-md-2">Email</label>
<div class="col-md-10">
<input class="form-control" id="email" name="email" type="text" placeholder="Email" required />
</div>
</div>
<input type='hidden' name='sid' value='<?php echo TWOCHECKOUT_SELLER_ID;?>' />
<input type='hidden' name='mode' value='2CO' />
<input type='hidden' name='li_0_type' value='product' />
<input type='hidden' name='li_0_name' value='<?php echo $product_name;?>' />
<input type='hidden' name='li_0_product_id' value='<?php echo $order_id;?>' />
<input type='hidden' name='li_0_price' value='<?php echo $total;?>' />
</div>
</div>
<div class="col-md-12 text-center">
<input type="submit" class="btn btn-success btn-sm" value="Complete Checkout">
</div>
</form>
Consider using standard checkout instead. It lets the customer add the coupon code in the review cart step

getting a button to sit with drop down menu

I'm doing a redesign for my class, and I can't get the button even with the drop down menu. I've been trying different ways but cant get them to line up.
http://jgoldd.github.io/wsp/Project/index.html
try this css:
button, input, select, textarea {
font-size: 100%;
margin: 0 0 0 10px;
vertical-align: baseline;
float: left;
}
and experiment it out! Good luck! :)
Have you tried using tables? Usually that solves everything.
Here's the working JSFIDDLE > http://jsfiddle.net/PV3p5/
And here's the HTML. Try it!
<table style="border:none;">
<tr>
<td>State:
<select name="state_list" id="state_list">
<option value="" selected="selected">Select a State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</td>
<td style="padding-left:50px;"> City:
<select name="main_city_list" id="city_list">
<option>albuquerque</option>
<option>amarillo</option>
<option>boulder</option>
<option>central sd</option>
<option>clovis-portales</option>
<option>colorado springs</option>
<option>denver</option>
<option>eastern colorado</option>
<option>farmington</option>
<option>fort collins</option>
<option>grand island</option>
<option>high rockies</option>
<option>lincoln</option>
<option>logan</option>
</select>
</td>
</tr>
</table>