Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Modifying something displayed from the DB using JS
Old 06-05-2005, 11:43 PM Modifying something displayed from the DB using JS
Average Talker

Posts: 21
Trades: 0
If I have the following in my html:

<?=$first_name31?> <?=$last_name31?>

and I run a JS in the body OnLoad, can I do something like:

<script language="javascript">
var newfirst="Bob"
function change_name()
<?=$first_name31?> =newfirst


Sorry, I have tried a few times but nothing seems to work.

-Dave in IL
sydcomebak is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-06-2005, 03:38 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,523
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
as PHP is server side and javascript is client side it probably won't

Explain what you are trying to do.
the code above will assign the value of newfirst to a variable called [value of $first_name31].
eg;
if $first_name31 contains "fred", you will have a JS variable called fred with a value of "Bob"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2005, 10:08 AM
Average Talker

Posts: 21
Trades: 0
I have a list of classes and their instructors that are attached to radio buttons. The class info is all stored in a database with the class instructor's name being brought to the html as <?=$first_name47?> <?=$last_name47?>.

Ex: () Class #1 - Joe Smith

If the class is full, I already have the routine disabling the radio button for that class. What I would like to do is add a "Class is Closed" notification, and I thought that I could modify the instructor's name in the same function that I disable the radio buttons.

Ex: () Class #1 - Class is Closed

Tell you what, rather than looking like a noob and posting the whole page for everyone to scroll through, you can view the code here:

http://www.wmaw2005.com/2005/registration/reg.txt

I hope this helps you.

I know LOTS of the code could be condensed and all, but I figure I can do that later once it all works. Laying everything out as simply as I can makes it easier to modify and get an idea of changes that occur without completely modifying the results of everything.

Thanks.

-Dave in IL
sydcomebak is offline
Reply With Quote
View Public Profile
 
Old 06-06-2005, 02:14 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,523
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
if you have the names in a seperate span with a unique ID (didn't look at the file) you can use something like this

Code:
<script type="text/javascript">
function ClosedTxt(ID) {
document.getElementById(ID).innerHTML = "Class is Closed";
}
</script>
then in your disable routine

Code:
ClosedTxt([ID of span to change]);
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 06-06-2005 at 02:17 PM.. Reason: crap typing
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2005, 05:57 PM
Average Talker

Posts: 21
Trades: 0
Man, I wish I understood what you meant by that. Is there any way you could show that using variables from my actual page? I think I might understand where you are going, but I'd like a little more clarification.

Here is the php page and how it looks when it runs:

www.wmaw2005.com/2005/registration/reg.php

If you want to see all of the code:

www.wmaw2005.com/2005/registration/reg.txt

-Dave in IL

Last edited by sydcomebak; 06-06-2005 at 06:00 PM..
sydcomebak is offline
Reply With Quote
View Public Profile
 
Old 06-06-2005, 06:36 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,523
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
 <span id="name_1"><?=$first_name1?> <?=$last_name1?></span>
Code:
if(<?=$enrolled1?> == <?=$capacity1?>)
 {      document.form1.group1[0].disabled = true;
         document.form1.group1[0].checked = false;
         ClosedTxt('name_1')
 }
repeat for each group etc.

Quite honestly a lot of the javascript is a little pointless. 95% of what you are using it for could all be covered server side. And a couple of loops in the PHP could easily get rid of all the hard coded stuff.
You are far better starting off with clean code and getting rid of all the deprecated font tags etc. because once it is working there will be less drive to start over and fix it.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2005, 07:27 PM
Average Talker

Posts: 21
Trades: 0
Thank you SOOOOO much!

I'll give your suggestion a try.

This project wasn't mine to start. The initial Webmaster went AWOL and I was assigned to "Do my best" in his absence. I'm not the greatest programmer in the world. Heck, I'm not really a good programmer. I'm just trying to get it to work before a deadline. =(

-Dave in IL
sydcomebak is offline
Reply With Quote
View Public Profile
 
Old 06-07-2005, 02:10 PM
Average Talker

Posts: 21
Trades: 0
It worked!

Thanks a ton!

-Dave in IL
sydcomebak is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Modifying something displayed from the DB using JS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.62004 seconds with 12 queries