How do I make disabled/enable in HTML? - xhtml

When I pick Coffee
check box group – enabled
button box group – disabled
When I pick Hot Coco
check box group – disabled
button box group – enabled
BELOW CODE:
<fieldset id="mixdrinks">
<!-- pull down or drop menu examples -->
<label><strong>Drinks Selection</strong></label><br />
<select name="drinks" id="drinks">
<option selected="selected" label="none" value="none">null</option>
<option value="Coffee">Coffee</option>
<option value="Tea">Tea</option>
<option value="Juice">Juice</option>
<option value="Milk">Milk</option>
<option value="Hot Chocolate">Hot Coco</option>
</select>
<br />
<!-- check box -->
<label><strong>What do you want in your coffee?</strong></label><br />
<input type="checkbox" name="sugar" id="Checkbox1" value="yes" tabindex="4" /> Sugar<br />
<input type="checkbox" name="milk" id="Checkbox2" value="yes" tabindex="5" /> Milk<br />
<input type="checkbox" name="cream" id="Checkbox3" value="yes" tabindex="6"/> Cream
<p>...more mix drinks...</p>
<!-- radio buttons -->
<label><strong>Do you want Whip Cream on your Hot Coco?:</strong></label><br />
<input type="radio" name="WhipCream" id="Radio1" value="yes" title="Yes" />Yes<br />
<input type="radio" name="WhipCream" id="Radio2" value="yes" title="No" />No<br />
<br />

To do what you're asking, you need something more than html, you need Javascript.
I learned javascript from W3Schools.

Something like this might help.
<select name="drinks" id="drinks">
<option selected="selected" label="none" value="none">null</option>
<option value="Coffee">Coffee</option>
<option value="Tea">Tea</option>
<option value="Juice">Juice</option>
<option value="Milk">Milk</option>
<option value="Hot Chocolate">Hot Coco</option>
</select>
<br />
<!-- check box -->
<div id="coffeeDetails">
<label><strong>What do you want in your coffee?</strong></label><br />
<input type="checkbox" name="sugar" id="Checkbox1" value="yes" tabindex="4" /> Sugar<br />
<input type="checkbox" name="milk" id="Checkbox2" value="yes" tabindex="5" /> Milk<br />
<input type="checkbox" name="cream" id="Checkbox3" value="yes" tabindex="6"/> Cream
<p>...more mix drinks...</p>
</div>
<!-- radio buttons -->
<div id="cocoDetails">
<label><strong>Do you want Whip Cream on your Hot Coco?:</strong></label><br />
<input type="radio" name="WhipCream" id="Radio1" value="yes" title="Yes" />Yes<br />
<input type="radio" name="WhipCream" id="Radio2" value="yes" title="No" />No<br />
<br />
</div>
<script type="text/javascript">
window.onload = function() {
var ddl = document.getElementById("drinks");
var coffeeDetails = document.getElementById("coffeeDetails");
var cocoDetails = document.getElementById("cocoDetails");
ddl.onchange = function() {
var beverage = ddl.options[ddl.selectedIndex].text;
if (beverage == "Coffee") {
cocoDetails.style.display = "none";
coffeeDetails.style.display = "block";
}
if (beverage == "Hot Coco") {
cocoDetails.style.display = "block";
coffeeDetails.style.display = "none";
}
}
};
</script>

Use javascript to alter the CSS DISPLAY attribute for a given HTML attribute:
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
..then update what you want to hide with something resembling:
<span onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</span>
<div id="foo">This is foo</div>
Reference: Toggle Visibility - Show/Hide Anything

You can use javascript to enable or disable the controls as:
var varName = document.getElementById('<%= this.buttonGroup.ClientID %>');
varName.disabled = true or false; accroding to ur requirements.
Cheers

Related

Fixed DIV when scrolling in a pop up window

I'm looking for a CSS/JQuery method of keeping a DIV (which contains navigation buttons) visible when scrolling or content extends the viewable window size.
I have come across CSS code like this:
.element { position:fixed; Bottom:0px }
But my request is for use within a pop up window / dialog and this code doesn't seem to work for my scenario.
I have a pop up window which displays a 'next' and 'previous' button at the bottom and each "page" is a fieldset which is animated in or out of view.
There are a few fieldsets which go beyond the height of the pop up window and so the scroll activates. But I want to keep my button DIV in view at all times, along the bottom of the pop up window.
Trying to use the CSS above does not seem to set the element within the pop up window, rather it is positioning based on the parent window.
Is there a way to create a fixed DIV to remain visible when scrolling within a pop up window?
Any help would be greatly appreciated.
EDIT:
Code for the pop up window:
<div id="win1" class="FormDiv">
<!-- multistep form -->
<form id="msform">
<!-- progressbar -->
<ul id="progressbar">
<li id="liDetails" class="active firstLi">User Details</li>
<li id="liLevel">Level Selection</li>
<li id="liAccess">Access Items</li>
<li id="liSummary">Summary</li>
</ul>
<!-- fieldsets -->
<fieldset id="fsDetails">
<h2 class="fs-title" id="FormStep1Title">Enter user details</h2>
#*<h3 class="fs-subtitle">This is step 1</h3>*#
<div class="fs-leftDiv">
<input type="text" name="RequestedFor" id="RequestedFor" placeholder="Requested For " readonly title="Requested For" tabindex="-1" />
<input type="text" name="DirectorateName" id="DirectorateName" placeholder="Directorate " title="Directorate" tabindex="1" style="border-color:red;" />
<input type="text" name="Dept" id="Dept" placeholder="Department " title="Department" tabindex="3" />
<input type="text" name="ForOtherStaff" id="ForOtherStaff" placeholder="Form For Other Staff? (Enter Username) " onblur="getUserForForm()" title="Form For Other Staff? (Enter Username)" tabindex="5" />
<select id="Title" name="Title" title="User Title" onchange="onTitleChange()" tabindex="7">
<option value="">Select Title...</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
</select>
<input type="hidden" name="UserName" id="UserName" /><input type="hidden" name="FormId" id="FormId" />
</div>
<div class="fs-rightDiv">
<input type="text" name="RequestDate" id="RequestDate" placeholder="Request Date " readonly title="Request Date" tabindex="-1" />
<select id="PhysicalSite" name="PhysicalSite" onchange="onSiteChange()" title="Site" tabindex="2" style="border-color:red;"></select>
<input type="text" name="PhoneNo" id="PhoneNo" placeholder="Phone Number " title="Phone Number" tabindex="4" />
<input type="text" name="Payroll" id="Payroll" placeholder="Payroll Number " title="Payroll Number" tabindex="6" />
<input type="text" name="ReplacedName" id="ReplacedName" placeholder="Replaced Name " title="Replaced Name" tabindex="8" />
<input type="hidden" name="UserEmail" id="UserEmail" /><input type="hidden" name="RequestId" id="RequestId" />
</div>
<input type="text" name="Comments" id="Comments" placeholder="Comments " title="Comments" tabindex="9" />
<div id="FixedScroll" class="fixedScroll">
<input type="button" name="save" class="save action-button" value="Save" tabindex="9" />
<input type="button" name="next" class="next action-button" value="Next" tabindex="10" />
</div>
</fieldset>
<fieldset id="fsLevel" title="hidden">
<h2 class="fs-title">Access Level / Item Selection</h2>
<h3 class="fs-subtitle">To add items using a role, please go to next section (Access Item)</h3>
<div id="AllAccessLevelDiv" style="margin-top:20px;">
<span class="GrpTitle" style="width:100%;text-align:left;">Access Level</span>
#(Html.Kendo().DropDownList()
.Name("AccessLevel")
.HtmlAttributes(new { style = "width:100%;text-align:left;margin-bottom:4px;float:left;" })
.DataTextField("Description")
.DataValueField("Code")
//.AutoBind(false)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetAccessLevelList", "Home").Type(HttpVerbs.Post);
});//.ServerFiltering(false);
})
.Events(e => e.Change("AccessListRebind"))
//.Events(e => e.DataBound("DropDownDefaults"))
)
<div id="lstAccessLevelDiv" style="display:none;padding:0px;margin:0px;">
#(Html.Kendo().MultiSelect()
.Name("lstAccessLevel")
.Events(e => e.Change("onAccessLevelItemChange"))
.AutoBind(false)
.IgnoreCase(true)
.Placeholder("Click here to select item(s) ......")
.HtmlAttributes(new { style = "width:100%; float:left;display:block;" })
.DataTextField("AccessItemDesc")
.DataValueField("AccessItemCode")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("GetAccessLevelItems", "Home").Type(HttpVerbs.Post)
.Data("AccessItemFilter")
)))
</div>
</div>
<div id="fsLevelDiv" style="text-align:left;width:100%;clear:both;padding:0px;margin:0px;">
</div>
<table id="AccessItemSummary1">
<thead>
<tr><th colspan="2">Summary of default / selected access items</th></tr>
<tr>
<th>Name</th>
<th>Value</th>
<th style="display:none">Id</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div id="FixedScroll1" class="fixedScroll">
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="save" class="save action-button" value="Save" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
</fieldset>
</fieldset>
</form>
</div>
The code for opening the pop up:
function OpenForm() {
var dialog, form;
dialog = $("#win1").dialog({
autoOpen: false,
height: 600,
width: 650,
modal: true,
center: true,
resizable: false,
});
dialog.center;
form = dialog.find("form").on("submit", function (event) {
event.preventDefault();
addUser();
});
var formId, requestStatus, modeColor;
var statusLabel = '';
if (pFormId) {
formId = ' Form Id: ' + pFormId;
statusLabel = '<label id="lblfooter3" class="StatusBar" style="position:relative; margin-bottom:0px; margin-left:160px; float:left; z-index:2000"><a style="color:#747A90; z-index:2000;" onclick="OpenStatusHistoryForm()">View Status History</a></label>'
}
else
formId = 'New Form';
if ((pRequestStatus == 'APPROVED') || (pRequestStatus == 'PENDING') || (pRequestStatus == 'REJECTED')) {
requestStatus = ' Read Only Mode ';
modeColor = 'indianred';
}
else {
requestStatus = ' Edit Mode ';
modeColor = 'darkgray';
}
dialog.dialog({ title: pSystemName + ' - ' + pFormTypeName });
dialog.dialog("open");
//stop main window scrolling
$('body').css('overflow', 'hidden');
$("#lblfooter").remove();
$("#lblfooter2").remove();
$("#lblfooter3").remove();
$("#win1").parent().append('<label id="lblfooter" class="StatusBar" style="position:relative;margin-bottom:0px; float:left; color:darkgray;z-index:2000">' + formId + '</label>' + statusLabel +
'<label id="lblfooter2" class="StatusBar" style="position:relative; margin-bottom:0px; float:right; color:' + modeColor + ';z-index:2000">' + requestStatus + '</label>');
}

Post back values without clearing page

Note: I've been using ASP.NET Webforms, so ViewState was my friend.
Note: Default.html and Default.cshtml are two different files/pages.
Basically, all I'm trying to do is take form values from a .html page, post them, and then go back to the original page without the values resetting.
Here's what I have so far:
My client-side script
<!-- Default.html -->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing Stuff</title>
</head>
<body>
<form id="mainpage" action="Default.cshtml" method="post">
<div style="clear:both;" id="dbInput">
<label for="linedesc">Description:</label>
<input type="text" id="linedesc" name="linedesc" />
<br /><br />
<input id="fruits" name="options1" value="fruits" type="radio" />
<label for="fruits">Fruits</label>
<input id="candies" name="options1" value="candies" type="radio" />
<label for="candies">Candies</label>
<input id="snacks" name="options1" value="snacks" type="radio" />
<label for="snacks">Snacks</label>
<br /><br />
<label for="options2">Choose beverage:</label>
<select id="options2" name="options2">
<option value="Coca-Cola">Coca-Cola</option>
<option value="Sprite">Sprite</option>
<option value="Root Beer">Root Beer</option>
<option value="Orange Juice">Orange Juice</option>
</select>
<br /><br />
<input type="submit" id="submit" name="submit" value="Submit" />
</div>
</form>
</body>
</html>
And my server-side script
//Default.cshtml
#{
var linedesc = Request.Form["linedesc"];
var food = Request.Form["options1"];
var drinks = Request.Form["options2"];
// Go back to Default.html and keep values selected, ie. values don't reset
var blah = "hi";
}
All I want to do is simple, no bells, no whistles, postback and return. I'm just missing that last piece.

Jquery mobile radio button selection

I'm trying to implement a horizontal control group in jquery mobile which has radio buttons inside. I am trying to build the HTML string dynamically from code behind.
These radio buttons are in a for loop .
StringBuilder tileString = new StringBuilder(string.Empty);
foreach (Product product in productsInCart)
{
tileString.Append("<div><legend >Choose shipping type:</legend></div><br />");
tileString.Append("<input type='radio' name='radio-choice-1' id='radio-choice-1' onclick='findPaymentMethod()' value='In Flight' checked='checked' />");
tileString.Append("<label for='radio-choice-1'>In flight</label>");
tileString.Append("<input type='radio' name='radio-choice-1' id='radio-choice-2' value='On Arrival' onclick='findPaymentMethod()' />");
tileString.Append("<label for='radio-choice-2'>On Arrival</label>");
} `
As you can see there is a property on the first radio button.
checked='checked'
But when this is run in a for loop only the last radio element in the for loop gets checked. Can anyone suggest me whats wrong with the code ? Or am i missing something here ?
EDIT: HTML string that gets generated is added .
<div data-role='fieldcontain'>
<fieldset data-role='controlgroup' data-type='horizontal' id='6' data-mini='true'>
<div>
<legend >Choose shipping type:</legend>
</div>
<br />
<input type='radio' name='radio-choice-1' id='radio-choice-16' value='In Flight' checked='checked'/>
<label for='radio-choice-16'>In flight</label>
<input type='radio' name='radio-choice-1' id='radio-choice-26' value='On Arrival' />
<label for='radio-choice-26'>On Arrival</label>
</fieldset>
</div>`
`<div data-role='fieldcontain'>
<fieldset data-role='controlgroup' data-type='horizontal' id='1' data-mini='true'>
<div>
<legend >Choose shipping type:</legend>
</div>
<br />
<input type='radio' name='radio-choice-1' id='radio-choice-11' value='In Flight' checked='checked'/>
<label for='radio-choice-11'>In flight</label>
<input type='radio' name='radio-choice-1' id='radio-choice-21' value='On Arrival' />
<label for='radio-choice-21'>On Arrival</label>
</fieldset>
</div>
Only 1 radio element is getting checked within the fieldset
Here's an image of the desired effect.
Your name attribute (like id one) must be unique.
Working example: http://jsfiddle.net/Gajotres/SBxVc/
<div data-role='fieldcontain'>
<fieldset data-role='controlgroup' data-type='horizontal' id='6' data-mini='true'>
<div>
<legend >Choose shipping type:</legend>
</div>
<br />
<input type='radio' name='radio-choice-16' id='radio-choice-16' value='In Flight' checked='checked'/>
<label for='radio-choice-16'>In flight</label>
<input type='radio' name='radio-choice-26' id='radio-choice-26' value='On Arrival' />
<label for='radio-choice-26'>On Arrival</label>
</fieldset>
</div>
<div data-role='fieldcontain'>
<fieldset data-role='controlgroup' data-type='horizontal' id='1' data-mini='true'>
<div>
<legend >Choose shipping type:</legend>
</div>
<br />
<input type='radio' name='radio-choice-11' id='radio-choice-11' value='In Flight' checked='checked'/>
<label for='radio-choice-11'>In flight</label>
<input type='radio' name='radio-choice-21' id='radio-choice-21' value='On Arrival' />
<label for='radio-choice-21'>On Arrival</label>
</fieldset>
</div>

Zombie.js can't find button element on page

I'm trying to submit a form with zombie.js, and pressButton() is failing with "Error: No BUTTON 'xxx'", where xxx is the selector. Here is the app:
var Browser = require('zombie');
b = new Browser();
b.visit('https://www.example.com/login/', function() {
b.
fill('name', 'My Name').
fill('code', 'My Code').
pressButton('submit', function() {
console.log(b.html());
});
});
And here is the form:
<form method="post" class="login">
<p> <label for="name"> <span id="nameprompt">Your Name:</span> </label> </p>
<input name="name" id="name" value="" size="40" maxlength="40" />
<p> <label for="code"> <span id="codeprompt">Bar Code</span> </label> </p>
<input name="code" id="code" type="PASSWORD" value="" size="40" maxlength="40" />
<div class="formButtonArea">
<input type="image" src="/screens/pat_submit.gif" border="0" name="submit" value="submit" />
</div>
</form>
I've tried a bunch of selectors including things like ".formButtonArea input" in addition to the obvious "submit" with no success.
What am I doing wrong?
It seems like you need the input to be of type="submit" (or type="button" perhaps). According to https://groups.google.com/forum/?fromgroups=#!topic/zombie-js/8L0_Cpn8vVU, where the author comments on clickLink, it's likely that clickButton will do the same: find buttons and then fire click.
Hope it helps.

Need ASP code for a simple form - radio buttons redirect to urls

Can someone direct me to an example of asp code that will process a form which has only radio buttons? The functionality: When a radio button is checked and submit is clicked the user will be redirected to specific url. onclick="window.location='http://www.google.com';" Will not do the trick here. We have to wait until "submit" is clicked.
<form name="input" action="the_code_you_are_helping_me_with.asp" method="get">
<input type="radio" name="option1" value="1" />option1<br />
<input type="radio" name="option2" value="2" />option2<br />
<input type="radio" name="option3" value="3" />option3<br />
<input type="radio" name="option4" value="4" />option4<br />
<input type="radio" name="option5" value="5" />option5<br />
<input type="submit" value="Submit" />
Thanks in advance,
dp
See a working demo here: http://jsfiddle.net/89s6R/3/
<script>
function onRadioClick(radio) {
radio.form.action = radio.value;
}
function onFormSubmit(form) {
window.location = form.action;
return false;
}
</script>
<form name="input" action="#" method="get" onsubmit="return onFormSubmit(this)">
<label><input type="radio" name="destination" onclick="onRadioClick(this)" value="http://google.com" />Google</label><br />
<label><input type="radio" name="destination" onclick="onRadioClick(this)" value="http://nyt.com" />New York Times</label><br />
<label><input type="radio" name="destination" onclick="onRadioClick(this)" value="http://twitter.com" />Twitter</label><br />
<label><input type="radio" name="destination" onclick="onRadioClick(this)" value="http://microsoft.com" />Microsoft</label><br />
<label><input type="radio" name="destination" onclick="onRadioClick(this)" value="http://apple.com" />Apple</label><br />
<input type="submit" value="Submit" />
</form>​
The above client-side answer will work. However, if you want "asp code" I assume you wanted something server side. So:
Turn your submit button into an asp:Button.
Turn your radio buttons into an asp:RadioButtonList.
In the button's onClick event, get the value of the selected button. Then user Response.Redirect to redirect to that url.

Resources