Solved

style textboxes as labels

Posted on 2011-09-19
3
323 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

821 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