Solved

style textboxes as labels

Posted on 2011-09-19
3
310 Views
Last Modified: 2012-05-12
I am just interested in the content of the textboxes.

Essentially, I want to make the information "read-only" by styling the textboxes as simple text labels.  Or I guess "turn them into" <span> tags.

How can I do this?

<div id="ctl00_ContentPlaceHolder1_BillingInfo1_aoebillfirstname" class="fieldformatting">First Name:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbFirstName" type="text" value="W" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbFirstName" style="width:255px;" /></div>

would become:

<div id="ctl00_ContentPlaceHolder1_BillingInfo1_aoebillfirstname" class="fieldformatting">First Name:  <span id="ctl00_ContentPlaceHolder1_BillingInfo1_tbFirstName" style="width:255px;">W</span></div>

The drop down lists would just show the selected option value as a label.

<div id="aeosubparaheader" class="aoebillingheader">
<b><span id="ctl00_ContentPlaceHolder1_BillingInfo1_BillingInfoHeader">Credit Card Billing Info:</span></b>
</div>
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_aoebillfirstname" class="fieldformatting">First Name:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbFirstName" type="text" value="W" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbFirstName" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div1" class="fieldformatting">

Last Name:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbLastName" type="text" value="W" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbLastName" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div2" class="fieldformatting">
Address:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbAddress1" type="text" value="W" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbAddress1" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div3" class="fieldformatting">
Address2:
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbAddress2" type="text" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbAddress2" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div4" class="fieldformatting">
City:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbCity" type="text" value="W" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbCity" style="width:255px;" /></div>


<div id="DivStateAndZip" class="billingstateandzipwrapper">
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div555" class="billingstatewrapper">
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div5" class="billingstatefieldformatting">
State:<font color="red">*</font></div>
<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div55" class="specialbillingstateddl"><select name="ctl00$ContentPlaceHolder1$BillingInfo1$statesuser$ddlState" id="ctl00_ContentPlaceHolder1_BillingInfo1_statesuser_ddlState" style="width:100px;">
	<option selected="selected" value="AL">Alabama</option>
	<option value="AK">Alaska</option>
	<option value="AZ">Arizona</option>
	<option value="AR">Arkansas</option>
...
...
	<option value="WV">West Virginia</option>
	<option value="WI">Wisconsin</option>
	<option value="WY">Wyoming</option>

</select>
</div>
</div>

<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div7" class="billingzipfieldformatting">
Zip:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbZip" type="text" value="A" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbZip" style="width:60px;" /></div>
</div>

<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div888" class="fieldformatting">
Country:<font color="red">*</font><select name="ctl00$ContentPlaceHolder1$BillingInfo1$countriesuser$ddlCountry" id="ctl00_ContentPlaceHolder1_BillingInfo1_countriesuser_ddlCountry" style="width:257px;">
	<option selected="selected" value="US">United States</option>

	<option value="AF">Afghanistan</option>
	<option value="AL">Albania</option>
	<option value="DZ">Algeria</option>
...
...
	<option value="US">United States</option>
	<option value="UM">United States Minor Is.</option>
	<option value="UY">Uruguay</option>
	<option value="UZ">Uzbekistan</option>
	<option value="VU">Vanuatu</option>

</select>

</div>

<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div9" class="fieldformatting">
E-Mail:<font color="red">*</font>
<input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbEmail" type="text" value="Tom.Knowlton@total-computing.com" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbEmail" style="width:255px;" />
</div>

<div id="" class="dayandnightphonewrapper">
    <div id="ctl00_ContentPlaceHolder1_BillingInfo1_dpff" class="dayphonefieldformatting">
    Day Phone:<font color="red">*</font>
    <input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbDayPhone" type="text" value="111day" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbDayPhone" style="width:90px;" />

    </div>
   
    <div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div11" class="nightphonefieldformatting">
    Evening:
    <input name="ctl00$ContentPlaceHolder1$BillingInfo1$tbNightPhone" type="text" value="eve" id="ctl00_ContentPlaceHolder1_BillingInfo1_tbNightPhone" style="width:90px;" />
    </div>
</div>

<div id="ctl00_ContentPlaceHolder1_BillingInfo1_Div12" class="keepinformedfieldformatting">
</div>

    

<div class="aoeshippingheader">
<b>Shipping Information:</b>

</div>

<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_copybillingtoshippingdiv" class="copybilltoship">
<input id="ctl00_ContentPlaceHolder1_ShippingInfo1_CheckBoxCopyBillToShip" type="checkbox" name="ctl00$ContentPlaceHolder1$ShippingInfo1$CheckBoxCopyBillToShip" onclick="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$ShippingInfo1$CheckBoxCopyBillToShip\',\'\')', 0)" /><label for="ctl00_ContentPlaceHolder1_ShippingInfo1_CheckBoxCopyBillToShip"> Same as Billing?</label>
</div>

<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div1" class="shippingfieldformatting">Ship to Name:<font color="red">*</font><input name="ctl00$ContentPlaceHolder1$ShippingInfo1$tbShipFirstName" type="text" value="W W" id="ctl00_ContentPlaceHolder1_ShippingInfo1_tbShipFirstName" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div2" class="shippingfieldformatting">Address:<font color="red">*</font><input name="ctl00$ContentPlaceHolder1$ShippingInfo1$tbShipAddress1" type="text" value="W" id="ctl00_ContentPlaceHolder1_ShippingInfo1_tbShipAddress1" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div3" class="shippingfieldformatting">Address2:<input name="ctl00$ContentPlaceHolder1$ShippingInfo1$tbShipAddress2" type="text" id="ctl00_ContentPlaceHolder1_ShippingInfo1_tbShipAddress2" style="width:255px;" /></div>
<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div4" class="shippingfieldformatting">City:<font color="red">*</font><input name="ctl00$ContentPlaceHolder1$ShippingInfo1$tbShipCity" type="text" value="W" id="ctl00_ContentPlaceHolder1_ShippingInfo1_tbShipCity" style="width:255px;" /></div>





<div id="shipstatezipwrap" class="shippingstateandzipwrapper">
<div id="Div555666" class="specialstatewrapper">
<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div5" class="shippingstatefieldformatting">State:<font color="red">*</font></div>
<div id="66" class="specialshippingstatedll"><select name="ctl00$ContentPlaceHolder1$ShippingInfo1$statesshipping$ddlState" id="ctl00_ContentPlaceHolder1_ShippingInfo1_statesshipping_ddlState" style="width:100px;">
	<option selected="selected" value="AL">Alabama</option>
	<option value="AK">Alaska</option>
	<option value="AZ">Arizona</option>
	<option value="AR">Arkansas</option>
...
...
	<option value="WV">West Virginia</option>
	<option value="WI">Wisconsin</option>
	<option value="WY">Wyoming</option>
</select>
</div>
</div>
<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div6" class="shippingzipfieldformatting">Zip:<font color="red">*</font><input name="ctl00$ContentPlaceHolder1$ShippingInfo1$tbShipZip" type="text" value="A" id="ctl00_ContentPlaceHolder1_ShippingInfo1_tbShipZip" style="width:60px;" /></div>
</div>
<div id="Div777888" class="shippingfieldformatting">
Country:<font color="red">*</font>
<select name="ctl00$ContentPlaceHolder1$ShippingInfo1$countriesshipping$ddlCountry" id="ctl00_ContentPlaceHolder1_ShippingInfo1_countriesshipping_ddlCountry" style="width:257px;">
	<option selected="selected" value="US">United States</option>
	<option value="AF">Afghanistan</option>
	<option value="AL">Albania</option>
	<option value="DZ">Algeria</option>
...
...
	<option value="US">United States</option>
	<option value="UM">United States Minor Is.</option>
	<option value="UY">Uruguay</option>
	<option value="UZ">Uzbekistan</option>
	<option value="VU">Vanuatu</option>
</select>

</div>

<div id="shipin" class="shipinstwrap">
<div id="ctl00_ContentPlaceHolder1_ShippingInfo1_Div8" class="shipinstrshippingfieldformatting"><div id="ctl00_ContentPlaceHolder1_ShippingInfo1_shipins" class="shipinstrtext">Ship Instructions:</div></div>
<textarea name="ctl00$ContentPlaceHolder1$ShippingInfo1$tbShipInstructions" rows="2" cols="20" id="ctl00_ContentPlaceHolder1_ShippingInfo1_tbShipInstructions" style="height:50px;width:255px;position:relative;float:left;margin-top:2px;"></textarea>
</div>


</div>





<table cellpadding="5" cellspacing="0" border="0" width="100%">
<tr>
<td valign="top" style="width:300px;">



&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="ctl00_ContentPlaceHolder1_lbGoToMyAccount" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$lbGoToMyAccount&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Click here to change your address on file</a><br />



</asp:Panel>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:12px;"><input id="ctl00_ContentPlaceHolder1_cbCustomShip" type="checkbox" name="ctl00$ContentPlaceHolder1$cbCustomShip" onclick="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$cbCustomShip\',\'\')', 0)" /><label for="ctl00_ContentPlaceHolder1_cbCustomShip">Check to use a 'this time only' shipping address</label></span>

Open in new window


0
Comment
Question by:knowlton
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 36562417
First try : http://jsfiddle.net/7emyt/
$(":text", ".fieldformatting").each(function() {
    $(this).replaceWith("<span id='" + $(this).attr("id") + "' style='" + $(this).attr("style") + "'>" + $(this).val() + "</span>")
})
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 100 total points
ID: 36562419
var input = $(".fieldformatting input");

var html = "<span id='" + input.attr("id") +"' style='" + input.attr("style") + "' >" + input.val() + "</span>";
 $(".fieldformatting input").remove();
 $(".fieldformatting").append(html);
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 36563090
thx
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now