CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 How to add some javascript to my HTML dynamically?

Print topic Send  topic

Author Message
maggiemel

Posts: 75
Posted: 01/16/2007, 9:41 AM

Hello, everybody. I use a link from a grid to a details which I modify dynamically based on a user's login priveleges. So, an end-user gets a link like <a href="view_details.asp"> while an administrator gets <a href="edit_details.asp">.

I would like it if the view_details.asp page opened in a pop-up window. My problem is that when I add the javascript onclick event to the HTML, it appears for both the view_details and the edit_details links (as expected). But in the code to modify the link, I don't see how I can add in an "onclick" event. Does anyone have any suggestions?

Many thanks in advance!
_________________
Melissa Cahill
http://www.hellcatmaggie.net/
View profile  Send private message
E43509

Posts: 283
Posted: 01/16/2007, 12:45 PM

Perhaps the low risk way to do this is to put two links on your page, one for admins, one for users. Add your JS logic as appropriate and hide or show that link in the before show event based on the security group they belong to.
There may be a more elegant solution, but I've used this to just get it done and simplify my life.
View profile  Send private message
maggiemel

Posts: 75
Posted: 01/16/2007, 2:09 PM

Hi, E43509! I actually figured out the elegant -- and stupidly easy -- way to do this. I just added a Label in the HTML view within the <a href> tag, like this:

<a href="{dynLink}" {dynJava} >

Then in the Before Show event, I set the value like this:

form.dynJava.Value = "onclick='OpenPopup(this.href,width=700,height=500);return false;' "

Make sure you set the Content Type of the Label to HTML, otherwise you get the code.

Works great!

_________________
Melissa Cahill
http://www.hellcatmaggie.net/
View profile  Send private message
peterr


Posts: 5971
Posted: 01/16/2007, 2:21 PM

That's a nice solution. Thanks for sharing.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
marcwolf


Posts: 361
Posted: 01/16/2007, 6:18 PM

Hi All

You can do a lot with labels that have the HTML property set.

You can insert HTML blocks of text (Very good for Dynamic or CMS style sites) or insert various block of javascript. One f my pages has just 3 labels. Each lable is filled in the before show with HTML text from the database. And this text is generated using a FCKeditor based page

With links I have found that it best to construct the links in their entirity and then put them in as a HTML label. With previous experience that CSS and its HTML interpreter can have problem with links that have been modified.

Take care all

Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
wkempees


Posts: 1679
Posted: 01/17/2007, 3:55 AM

Strong tool + strong community = success.

Indeed thanks for sharing.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.