/    Sign up×
Community /Pin to ProfileBookmark

Save and Cancel buttons should display

I have some javascript code that is being moved from one site to another. In my original site when I am in a page profile.php when I click on an edit button all my form fields are made editable when I click on a Edit text and a two new buttons save and cancel appear.

First the html around the section I am having a problem with

[code]
<form name=”editProfile” id=”editProfile”>
<tr bgcolor=”#E4E9ED” class=”mid”>
<td bgcolor=”#E4E9ED” class=”BOT”><div align=”left”><strong>
<?=$first_name.” “.$last_name?> </strong></div>
</td>
<td align=”right” bgcolor=”#E4E9ED” class=”BOT”><strong> <span class=”mid” id=”editProfLink” style=”cursor:pointer;cursor:hand ; font-weight:bold” onclick=”makeEditableProfile()”>Edit profile</span> <span id=”savingProfile” style=”display:none”>Saving…</span> </strong> <span id=”editProfileBut” style=”display:none”>

<input name=”save” type=”button” onclick=”editProfileProc()” id=”save” value=”Save” class=”mid” />
<input name=”cancel” type=”button” id=”cancel” value=”Cancel” onclick=”makeReadonlyProfile()” class=”mid” />
</span> </td>
</tr>
[/code]

When I click on Edit profile it calls the javascript makeEditableProfile() show below

[code]
function makeEditableProfile() {
var ob = document.editProfile;
for (i = 0; i < ob.elements.length; i++) {
if (ob.elements[i].type == “text”) {
ob.elements[i].className = ‘edit’;
ob.elements[i].readOnly = false;

}
}
$(‘editProfLink’).style.display=’none’;
$(‘editProfileBut’).style.display = ”;
}
[/code]

If I understand correctly this javascript should chang the style editProfileBut to be displayed which will then have it display the buttons.

I’ve verified this is css related by turning off css in firefox and all the various buttons appear. I’m just not sure what is going wrong in the actually site. I am especially wondering what would stop working as I move from one site to another.

Thanks for any help

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@jake_dMar 31.2008 — $('editProfLink').style.display='none';
[/QUOTE]


pretty sure the actual code should be [CODE]style.display = 'hidden';[/CODE]
Copy linkTweet thisAlerts:
@michaelh613authorMar 31.2008 — pretty sure the actual code should be [CODE]style.display = 'hidden';[/CODE][/QUOTE]

The site I am workin one essentially is moving working code from one site to a new one with a different look and feel. So this code actually worked on an old site so I am trying to think what could be changing between the sites that I am missing
Copy linkTweet thisAlerts:
@jake_dMar 31.2008 — not sure, but maybe since you last used your site, you downloaded a more modern browser. I just checked to make sure, 'none' is not a valid css attribute for visibility.

EDIT: just realized you are using display as opposed to visibility (sorry I only use visibility, so I automatically see it instead of display). None is a valid css property for display, so I have no idea why that doesn't work. Sorry.
Copy linkTweet thisAlerts:
@michaelh613authorMar 31.2008 — The old site is still active and works in the same browsers I am having the problem with the new site. IE 7 and Firefox. I did check the standards


CSS properties can also be dynamically changed with a JavaScript.

Scripting Syntax: object.style.display="none"


http://www.w3schools.com/css/pr_class_display.asp

So it appears the syntax is correct. My problem isn't buttons disappearing but that they are not appearing.
Copy linkTweet thisAlerts:
@jake_dMar 31.2008 — do you change the display style back to "block"?
Copy linkTweet thisAlerts:
@michaelh613authorMar 31.2008 — I am not sure what you mean by back. It never was set to block on the old or new platform
Copy linkTweet thisAlerts:
@jake_dMar 31.2008 — well, if you want something to reappear after setting it's display to none, the traditional way of doing this is to change it's display attribute to block. You know what might be the the problem? Maybe your old style sheet had all <p> tags or even the body display set to "block" so that when you set those button's display to null, it automatically went back to block. However, in you new style sheet there is no default display to block. Maybe that's it.
Copy linkTweet thisAlerts:
@michaelh613authorMar 31.2008 — I tried this change but did not resolve the problem

function makeEditableProfile() {

var ob = document.editProfile;

for (i = 0; i < ob.elements.length; i++) {

if (ob.elements[i].type == "text") {

ob.elements[i].className = 'edit';

ob.elements[i].readOnly = false;



}
}
$('editProfLink').style.display='none';
$('editProfileBut').style.display = 'block';
×

Success!

Help @michaelh613 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...