Re: [PHP-DB] javascript and php
Perry, Matthew (Fire Marshal's Office) wrote: Hello all, I am having difficulties working with a JavaScript menu that should load on each page of my intranet site. [snip] hint - you're already on the wrong list. Read on. Here is a brief background of the problem: [snip] 4) I am using a JavaScript application for my navigation menu. I chose this because I need collapsing menus. There are lots of functions under each category; if I were to use HTML for the menu, my users would have to scroll way down to get to where they want to go - especially the ones still using 800X600 monitor resolution. A php function calls the JavaScript menu and changes what is displayed based on the session array data. Here is the problem: My JavaScript menu DOES NOT always display. It displays about 95% of the time. When it displays, it displays correctly (based on the session data). When it doesn't display, I hit reload and it usually reappears. What's worse, it seems to happen randomly! I could click the same link 10 times and it will work perfectly. The 11th time it might not show up. Here is the small amount of information I know about the problem: I have read through the list server achieves and think the problem may lie with the fact that Javascript has to run at the Web Browser end and PHP has to run at Server Side. This probably explains how it is possible that the two are not in sync but it does not explain WHY this happens about 5% of the time. It also does not explain why it happens only to the JavaScript while always displaying the results of my php functions. [snip] Your problem is that your javascript menu functions don't use an onload handler. What you need to realize is that the DOM may not have finished loading all the objects in the page, even though the object may have been printed out to the browser. so the (pseudo code) equivalent of: ---
operation_button = my_find_item_func('op');
--- may be holding null for 'operation_button' because op hasn't been added to the DOM yet. You have to wait until the page fully loads, then call a function to find that 'op' button. The reason it works most of the time, is probably because it's not being triggered until you mouseover the menu. Try loading the page with your mouse nowhere near where the menus should go, and the problem may 'disappear' (note: obviously not a solution). There's no guarantee, but that's a distinct possibility. Search for body.onload or window.onload functions. Also, whatever dropdown code you're using - if they don't describe doing this, you probably can find better. Any sane packaged dropdown code should be explicit about requiring the user to use onload to instantiate things. Cheers, -- - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] javascript and php
Hello all, I am having difficulties working with a JavaScript menu that should load on each page of my intranet site. Here is a brief background of the problem: 1) I am using PHP and SQL Server and it is running on Windows 2000 Server (yes I know this stinks but I have no choice in my office). 2) My users first log in. Login information is saved in the PHP session array. This information dynamically adjusts what the users will see from that point on. The higher the access level the more "stuff" they can see. This should be pretty common. 3) All of my PHP functions display information correctly based on the data stored in the session array. For example, if the user has an administrative login, SSN and rate of pay are displayed while this data is not displayed for other employees. 4) I am using a JavaScript application for my navigation menu. I chose this because I need collapsing menus. There are lots of functions under each category; if I were to use HTML for the menu, my users would have to scroll way down to get to where they want to go - especially the ones still using 800X600 monitor resolution. A php function calls the JavaScript menu and changes what is displayed based on the session array data. Here is the problem: My JavaScript menu DOES NOT always display. It displays about 95% of the time. When it displays, it displays correctly (based on the session data). When it doesn't display, I hit reload and it usually reappears. What's worse, it seems to happen randomly! I could click the same link 10 times and it will work perfectly. The 11th time it might not show up. Here is the small amount of information I know about the problem: I have read through the list server achieves and think the problem may lie with the fact that Javascript has to run at the Web Browser end and PHP has to run at Server Side. This probably explains how it is possible that the two are not in sync but it does not explain WHY this happens about 5% of the time. It also does not explain why it happens only to the JavaScript while always displaying the results of my php functions. Here are my questions: 1) How can make this menu display 100% of the time? I realize this may be hard to answer without looking at all of my code. 2) Should I stop using JavaScript? If so, what should I use instead that allows collapsing menus? Thank you for your time, - Matthew Perry
Re: [PHP-DB] Javascript help require
Rinku! It's PHP-DB List! If you wanna know JavaScript, Outlook, maybe TheBat!, Mozilla etc. send your messages into it' own maillist! Your letters only provoke, I think, everybody, and you'll wait for replies endlessly... Sorry but it's a fact. Saturday, June 26, 2004, 6:04:48 PM, Rinku wrote: R> I need Javascript help for this R> 1)I want to validate a variable called "name" R> If variable's value is not set then system should say R> "Value require". R> If its not alphabatic then system should say R> "Alphabatic value require". And curser's focus should R> come on textbox named "name". R> 2)I want to validate a variable called "Phone_no" R> If variable's value is not set then system should say R> "Value require". R> If its not numeric then system should say "Numeric R> value require". And curser's focus should come on R> textbox named "Phone_no". R> Pls answer if you can. I have tried but not 100% R> succeed. R> Regards R> Rinku R> __ R> Do you Yahoo!? R> Take Yahoo! Mail with you! Get it on your mobile phone. R> http://mobile.yahoo.com/maildemo -- Best regards, Mikhail U. Petrov mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Javascript help require
I need Javascript help for this 1)I want to validate a variable called "name" If variable's value is not set then system should say "Value require". If its not alphabatic then system should say "Alphabatic value require". And curser's focus should come on textbox named "name". 2)I want to validate a variable called "Phone_no" If variable's value is not set then system should say "Value require". If its not numeric then system should say "Numeric value require". And curser's focus should come on textbox named "Phone_no". Pls answer if you can. I have tried but not 100% succeed. Regards Rinku __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript question
alert(''); // case sensitive - Original Message - From: "Gamze Başaran" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 08, 2004 4:09 PM Subject: [PHP-DB] javascript question When I use this it isn't work an there is error but ı can't see it with internet explorer. I can't catch it :( Alert(''); or Alert(''); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] javascript question
When I use this it isn't work an there is error but ı can't see it with internet explorer. I can't catch it :( Alert(''); or Alert(''); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript question
Maybe you forgot a "?": Alert(); or ^^^ Ignatius _ - Original Message - From: "Gamze Başaran" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 08, 2004 2:49 PM Subject: [PHP-DB] javascript question > Hi everyone; > > First of all I'm sorry maybe I musn't send this mail to this list but I > think that someone can help me. Here is my problem: > > I use pear templates. In my html template file there is an javascript like > this: > > function validateAll (objForm){ > if (objForm.comp_prg.selectedIndex == 0) { > alert ("You must choose something"); > return false; > } > Return true; > } > > This code is true. But I want to use php variable in this code. Alert > sentence must be a php_variable. I try > > Alert(); or > Alert(); > > But I it isn't work. Can anybody help me?? > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript question
Gamze Başaran <[EMAIL PROTECTED]To: "Php-Db ([EMAIL PROTECTED])" <[EMAIL PROTECTED]> aat.com.tr> cc: Subject: [PHP-DB] javascript question 03/08/2004 08:49 AM Hi everyone; First of all I'm sorry maybe I musn't send this mail to this list but I think that someone can help me. Here is my problem: I use pear templates. In my html template file there is an javascript like this: function validateAll (objForm){ if (objForm.comp_prg.selectedIndex == 0) { alert ("You must choose something"); return false; } Return true; } This code is true. But I want to use php variable in this code. Alert sentence must be a php_variable. I try Alert(); or Alert(); The tags are not valid php opening/closing tags, you alse have PHP and Javascript sytax errors. probably php-general is the best place for this post. Although this should work. if you don't use a qoute(') in JS alerts then JS will think its a variable name and not a string to be alerted. Alert(''); or Alert(''); hth Jeff --- But I it isn't work. Can anybody help me?? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] javascript question
Hi everyone; First of all I'm sorry maybe I musn't send this mail to this list but I think that someone can help me. Here is my problem: I use pear templates. In my html template file there is an javascript like this: function validateAll (objForm){ if (objForm.comp_prg.selectedIndex == 0) { alert ("You must choose something"); return false; } Return true; } This code is true. But I want to use php variable in this code. Alert sentence must be a php_variable. I try Alert(); or Alert(); But I it isn't work. Can anybody help me?? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Javascript+PHP+MySQL
I have a question of Javascript, I don't whether anyone has experience this before, but I think some of you must have. I have the following main form, with a field called location, in which I had used the SELECT html tag and also at the same time, the content for the location field is actually extract from a MySQL table called location. --- Please select a hometown --- $sqlstmt = "SELECT * FROM locations ORDER BY location"; $result = mysql_query ($sqlstmt); while ($row = mysql_fetch_object ($result)) { ?> location; ?> } ?> This is only a portion of the main form, as you notice I have a button which will open a new window and call another script called managetown.php In this managetown.php, you are allowed to add new locations. When adding new locations, my intention was to submit an INSERT sqlstmt and add the new location into the location table (MySQL db). And at the same time I had also used Javascript to dynamically add the new value into the parent window by using the following javascript function. function update_selectbox (fieldName, id, value) { field = opener.document.forms[0].eval (fieldName); new_field_elem = new Option (value, id); field.options[field.length] = new_field_elem; return true; } Now my problem is, that this will only work in Netscape 4.x and works nicely in Netscape 7.1, but unfortunately it doesn't if ran on IE. Would appreciate if anyone could advise me why it doesn't run properly on IE. Regards and thanks in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
This works! Thanks Adam On Tue, 2003-01-14 at 03:11, Adam Royle wrote: > Hi Mignon, > > This should work, never closing the window without submitting > (foolproof). Just add some error checking, and you'll be sweet as a > nut! All I did was add the echo statement underneath the data insert. > > Adam > > > include ('dbconn.php'); > if(isset($submit)) >{ > $query = "INSERT INTO `comments` ( `track_id`, `cat_comments` ) > VALUES ( '0', '$comm' );"; > mysql_query ($query, $link ); > > echo ' language="JavaScript">window.close(); html>'; > > } > ?> > > > > > > > > Enter your details here: > > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
Thanks again for the advice. This approach wont work in this case because I'm launching the window from an app, then I need to close to return to the app. If I submit back to my app, it brings a new app into the addl window. And no, you're definetly not stupid ! Thanks for the help. Mignon On Mon, 2003-01-13 at 15:51, Micah Stevens wrote: > > Wait, I'm stupid. You're closing the window upon submission of the form, > so that will close the session, so the php at the beginning will never > process after form submission. Make the form submit to another page that > won't be closed. > > -Micah > > On Mon, 2003-01-13 at 13:24, Mignon Hunter wrote: > > > Unfortunately I havnt gotten it to work yet. Am I missing something ? > > > > PS the query works without the closewindow() > > > > > include ('dbconn.php'); > > if(isset($submit)) > > { > > $query = "INSERT INTO `comments` ( `track_id`, `cat_comments` ) VALUES > > ( '0', '$comm' );"; > > mysql_query ($query, $link ); > > } > > ?> > > > > > > > > > > > > > > > > > > > > Enter your details here: > > > > > > > onClick="return window.close();"> > > > > > > > > > > > > > > On Mon, 2003-01-13 at 14:44, Micah Stevens wrote: > > > The window.close(); function is not returning control to the form after > > > closing the window. You must tell it to do so. Use: > > > > > > onClick="return window.close();" > > > > > > This will return the window.close() value to the submit button so that > > > it can do its thing after the window has been closed. > > > > > > Use the same thing for the other form items too. > > > > > > Hope this helps. > > > -Micah > > > > > > > > > > > > On Mon, 2003-01-13 at 12:31, Mignon Hunter wrote: > > > > > > > Hello List, > > > > > > > > Has anyone had any problems using the onClick="window.close();" > > > > function within a input type = "submit" ? > > > > > > > > I'm trying > > > > > > > > > > > onClick="window.close();"> > > > > > > > > But evidently it's reading the close before the submit because the value > > > > of my form var is not being passed. > > > > > > > > I have also tried it in conjunction with a hidden field too. > > > > > > > > > > > > > > > onClick="window.close();"> > > > > > > > > If I dont use the onclick() the variable gets passed and/or entered into > > > > db just fine. > > > > > > > > Curious if anyone has had this problem or if anyone has any ideas...Thx > > > > Mignon > > > > > > -- > > > Raincross Technologies > > > Development and Consulting Services > > > http://www.raincross-tech.com > > > > > > > -- > Raincross Technologies > Development and Consulting Services > http://www.raincross-tech.com > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
Hi Mignon, This should work, never closing the window without submitting (foolproof). Just add some error checking, and you'll be sweet as a nut! All I did was add the echo statement underneath the data insert. Adam include ('dbconn.php'); if(isset($submit)) { $query = "INSERT INTO `comments` ( `track_id`, `cat_comments` ) VALUES ( '0', '$comm' );"; mysql_query ($query, $link ); echo 'window.close();'; } ?> Enter your details here: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
Wait, I'm stupid. You're closing the window upon submission of the form, so that will close the session, so the php at the beginning will never process after form submission. Make the form submit to another page that won't be closed. -Micah On Mon, 2003-01-13 at 13:24, Mignon Hunter wrote: > Unfortunately I havnt gotten it to work yet. Am I missing something ? > > PS the query works without the closewindow() > > include ('dbconn.php'); > if(isset($submit)) >{ > $query = "INSERT INTO `comments` ( `track_id`, `cat_comments` ) VALUES > ( '0', '$comm' );"; > mysql_query ($query, $link ); > } > ?> > > > > > > > > > > Enter your details here: > > > onClick="return window.close();"> > > > > > > > On Mon, 2003-01-13 at 14:44, Micah Stevens wrote: > > The window.close(); function is not returning control to the form after > > closing the window. You must tell it to do so. Use: > > > > onClick="return window.close();" > > > > This will return the window.close() value to the submit button so that > > it can do its thing after the window has been closed. > > > > Use the same thing for the other form items too. > > > > Hope this helps. > > -Micah > > > > > > > > On Mon, 2003-01-13 at 12:31, Mignon Hunter wrote: > > > > > Hello List, > > > > > > Has anyone had any problems using the onClick="window.close();" > > > function within a input type = "submit" ? > > > > > > I'm trying > > > > > > > > onClick="window.close();"> > > > > > > But evidently it's reading the close before the submit because the value > > > of my form var is not being passed. > > > > > > I have also tried it in conjunction with a hidden field too. > > > > > > > > > > > onClick="window.close();"> > > > > > > If I dont use the onclick() the variable gets passed and/or entered into > > > db just fine. > > > > > > Curious if anyone has had this problem or if anyone has any ideas...Thx > > > Mignon > > > > -- > > Raincross Technologies > > Development and Consulting Services > > http://www.raincross-tech.com > > > -- Raincross Technologies Development and Consulting Services http://www.raincross-tech.com
Re: [PHP-DB] javascript and submitting forms
Nevermind Micah, Thanks for your input, I just did 2 buttons for the user - one to submit and one to close the window. Thanks for your help Mignon On Mon, 2003-01-13 at 15:24, Mignon Hunter wrote: > Unfortunately I havnt gotten it to work yet. Am I missing something ? > > PS the query works without the closewindow() > > include ('dbconn.php'); > if(isset($submit)) >{ > $query = "INSERT INTO `comments` ( `track_id`, `cat_comments` ) VALUES > ( '0', '$comm' );"; > mysql_query ($query, $link ); > } > ?> > > > > > > > > > > Enter your details here: > > > onClick="return window.close();"> > > > > > > > On Mon, 2003-01-13 at 14:44, Micah Stevens wrote: > > The window.close(); function is not returning control to the form after > > closing the window. You must tell it to do so. Use: > > > > onClick="return window.close();" > > > > This will return the window.close() value to the submit button so that > > it can do its thing after the window has been closed. > > > > Use the same thing for the other form items too. > > > > Hope this helps. > > -Micah > > > > > > > > On Mon, 2003-01-13 at 12:31, Mignon Hunter wrote: > > > > > Hello List, > > > > > > Has anyone had any problems using the onClick="window.close();" > > > function within a input type = "submit" ? > > > > > > I'm trying > > > > > > > > onClick="window.close();"> > > > > > > But evidently it's reading the close before the submit because the value > > > of my form var is not being passed. > > > > > > I have also tried it in conjunction with a hidden field too. > > > > > > > > > > > onClick="window.close();"> > > > > > > If I dont use the onclick() the variable gets passed and/or entered into > > > db just fine. > > > > > > Curious if anyone has had this problem or if anyone has any ideas...Thx > > > Mignon > > > > -- > > Raincross Technologies > > Development and Consulting Services > > http://www.raincross-tech.com > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
Unfortunately I havnt gotten it to work yet. Am I missing something ? PS the query works without the closewindow() Enter your details here: On Mon, 2003-01-13 at 14:44, Micah Stevens wrote: > The window.close(); function is not returning control to the form after > closing the window. You must tell it to do so. Use: > > onClick="return window.close();" > > This will return the window.close() value to the submit button so that > it can do its thing after the window has been closed. > > Use the same thing for the other form items too. > > Hope this helps. > -Micah > > > > On Mon, 2003-01-13 at 12:31, Mignon Hunter wrote: > > > Hello List, > > > > Has anyone had any problems using the onClick="window.close();" > > function within a input type = "submit" ? > > > > I'm trying > > > > > onClick="window.close();"> > > > > But evidently it's reading the close before the submit because the value > > of my form var is not being passed. > > > > I have also tried it in conjunction with a hidden field too. > > > > > > > onClick="window.close();"> > > > > If I dont use the onclick() the variable gets passed and/or entered into > > db just fine. > > > > Curious if anyone has had this problem or if anyone has any ideas...Thx > > Mignon > > -- > Raincross Technologies > Development and Consulting Services > http://www.raincross-tech.com > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
The window.close(); function is not returning control to the form after closing the window. You must tell it to do so. Use: onClick="return window.close();" This will return the window.close() value to the submit button so that it can do its thing after the window has been closed. Use the same thing for the other form items too. Hope this helps. -Micah On Mon, 2003-01-13 at 12:31, Mignon Hunter wrote: > Hello List, > > Has anyone had any problems using the onClick="window.close();" > function within a input type = "submit" ? > > I'm trying > > onClick="window.close();"> > > But evidently it's reading the close before the submit because the value > of my form var is not being passed. > > I have also tried it in conjunction with a hidden field too. > > > onClick="window.close();"> > > If I dont use the onclick() the variable gets passed and/or entered into > db just fine. > > Curious if anyone has had this problem or if anyone has any ideas...Thx > Mignon -- Raincross Technologies Development and Consulting Services http://www.raincross-tech.com
Re: [PHP-DB] javascript and submitting forms
Hello List, Has anyone had any problems using the onClick="window.close();" function within a input type = "submit" ? I'm trying But evidently it's reading the close before the submit because the value of my form var is not being passed. I have also tried it in conjunction with a hidden field too. If I dont use the onclick() the variable gets passed and/or entered into db just fine. Curious if anyone has had this problem or if anyone has any ideas...Thx Mignon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Javascript
Thanks for the tip. Well, my problem came from that parseInt() did not do the expected job. Like in: field1 = parseInt( thisform.field1.value ) + parseInt( thisform.field2.value ) ; If you happen to know the reason, I would love to know. Ignatius - Original Message - From: "Simon Taylor" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 11, 2002 4:03 PM Subject: RE: [PHP-DB] Javascript > The reason for this is these fields are regarded as text and unless you > specify number(variable) it may treat it as text.. When > Field1='0' > Field2='1' > Field3='2' > > Field1+Field2+Field3 = '012' > > If you use > Field1=Number('0') > Field2=Number('1') > Field3=Number('2') > > Field1+field2+field3 = 3 > > Cheers > Simon > > -Original Message----- > From: Ignatius Reilly [mailto:[EMAIL PROTECTED]] > Sent: 11 October 2002 15:48 > To: Shahmat Dahlan; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Javascript > > > I have met this problem before. > > The only solution I have found is to assign "0" values to the INPUT tags: > > > HTH > Ignatius > ____________ > - Original Message - > From: "Shahmat Dahlan" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, October 11, 2002 11:34 AM > Subject: [PHP-DB] Javascript > > > > My question might have anything to do with PHP but I have the > > following > > scenario: > > > > Say I have four fields > > field1 : > > field2 : > > field3 : > > field4 : > > > > And a total sum field, which is a total sum of the value of the > > expression, totalsum = field1 + field2 + field3 + field4 > > Total sum : XXX > > > > You would need to use Javascript to extract the value of field1, > > field2, > > field3, field4, initiated by the Javascript onChange event. > > > > The HTML codes should look like this: > > > > > > > > > > > > > > So the add function snippet that I have: > > > > function add() > > { > > var thisform=document.forms[0]; > > var field1=thisform.field1.value; > > var field2=thisform.field2.value; > > var field3=thisform.field3.value; > > var field4=thisform.field4.value; > > var totalqty=field1+field2+field3+field4; > > thisform.totalsum.value=totalqty; > > } > > > > But all I got is a NaN which means Not A Number. I understand that you > > solve this by using the parseInt Javascript function. > > But still all i get is a NaN value. > > > > Would appreciate if someone could help me out on this. > > > > Regards > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] R: [PHP-DB] Javascript
Try this: The HTML codes should look like this: function add() { var total = 0; var thisform = document.forms[0]; for (i=0;i<=thisform.elements["field[]"].length;i++) { if (!isNaN(thisform.elements["field[]"].value) total += thisform.elements["field[]"].value; } thisform.totalsum.value=total; } -Messaggio originale- Da: Shahmat Dahlan [mailto:[EMAIL PROTECTED]] Inviato: venerdi 11 ottobre 2002 11.35 A: [EMAIL PROTECTED] Oggetto: [PHP-DB] Javascript My question might have anything to do with PHP but I have the following scenario: Say I have four fields field1 : field2 : field3 : field4 : And a total sum field, which is a total sum of the value of the expression, totalsum = field1 + field2 + field3 + field4 Total sum : XXX You would need to use Javascript to extract the value of field1, field2, field3, field4, initiated by the Javascript onChange event. The HTML codes should look like this: So the add function snippet that I have: function add() { var thisform=document.forms[0]; var field1=thisform.field1.value; var field2=thisform.field2.value; var field3=thisform.field3.value; var field4=thisform.field4.value; var totalqty=field1+field2+field3+field4; thisform.totalsum.value=totalqty; } But all I got is a NaN which means Not A Number. I understand that you solve this by using the parseInt Javascript function. But still all i get is a NaN value. Would appreciate if someone could help me out on this. Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Javascript
I have met this problem before. The only solution I have found is to assign "0" values to the INPUT tags: HTH Ignatius - Original Message - From: "Shahmat Dahlan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 11, 2002 11:34 AM Subject: [PHP-DB] Javascript > My question might have anything to do with PHP but I have the following > scenario: > > Say I have four fields > field1 : > field2 : > field3 : > field4 : > > And a total sum field, which is a total sum of the value of the > expression, totalsum = field1 + field2 + field3 + field4 > Total sum : XXX > > You would need to use Javascript to extract the value of field1, field2, > field3, field4, initiated by the Javascript onChange event. > > The HTML codes should look like this: > > > > > > > So the add function snippet that I have: > > function add() > { > var thisform=document.forms[0]; > var field1=thisform.field1.value; > var field2=thisform.field2.value; > var field3=thisform.field3.value; > var field4=thisform.field4.value; > var totalqty=field1+field2+field3+field4; > thisform.totalsum.value=totalqty; > } > > But all I got is a NaN which means Not A Number. I understand that you > solve this by using the parseInt Javascript function. > But still all i get is a NaN value. > > Would appreciate if someone could help me out on this. > > Regards > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] R: [PHP-DB] Javascript
I will try your method. I have found a way to solved this problem of mine. I have four fields I may or may not choose to fill up one out of the four fields, or I might filled up all of them. So when I leave one or two fields empty, and add all the value up, I will get NaN. For those empty fields, it would be better to check and see whether it is blank, e.g. if (field1 == '') { field=0; } And then add them all up from there. Riccardi Moreno wrote: > Try this: > > The HTML codes should look like this: > > > > > > > function add() { > var total = 0; > var thisform = document.forms[0]; > for (i=0;i<=thisform.elements["field[]"].length;i++) { > if (!isNaN(thisform.elements["field[]"].value) total += > thisform.elements["field[]"].value; > } > thisform.totalsum.value=total; > } > > -Messaggio originale- > Da: Shahmat Dahlan [mailto:[EMAIL PROTECTED]] > Inviato: venerdi 11 ottobre 2002 11.35 > A: [EMAIL PROTECTED] > Oggetto: [PHP-DB] Javascript > > My question might have anything to do with PHP but I have the following > scenario: > > Say I have four fields > field1 : > field2 : > field3 : > field4 : > > And a total sum field, which is a total sum of the value of the > expression, totalsum = field1 + field2 + field3 + field4 > Total sum : XXX > > You would need to use Javascript to extract the value of field1, field2, > field3, field4, initiated by the Javascript onChange event. > > The HTML codes should look like this: > > > > > > > So the add function snippet that I have: > > function add() > { > var thisform=document.forms[0]; > var field1=thisform.field1.value; > var field2=thisform.field2.value; > var field3=thisform.field3.value; > var field4=thisform.field4.value; > var totalqty=field1+field2+field3+field4; > thisform.totalsum.value=totalqty; > } > > But all I got is a NaN which means Not A Number. I understand that you > solve this by using the parseInt Javascript function. > But still all i get is a NaN value. > > Would appreciate if someone could help me out on this. > > Regards > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php smime.p7s Description: S/MIME Cryptographic Signature
RE: [PHP-DB] Javascript
The reason for this is these fields are regarded as text and unless you specify number(variable) it may treat it as text.. When Field1='0' Field2='1' Field3='2' Field1+Field2+Field3 = '012' If you use Field1=Number('0') Field2=Number('1') Field3=Number('2') Field1+field2+field3 = 3 Cheers Simon -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED]] Sent: 11 October 2002 15:48 To: Shahmat Dahlan; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Javascript I have met this problem before. The only solution I have found is to assign "0" values to the INPUT tags: HTH Ignatius - Original Message - From: "Shahmat Dahlan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 11, 2002 11:34 AM Subject: [PHP-DB] Javascript > My question might have anything to do with PHP but I have the > following > scenario: > > Say I have four fields > field1 : > field2 : > field3 : > field4 : > > And a total sum field, which is a total sum of the value of the > expression, totalsum = field1 + field2 + field3 + field4 > Total sum : XXX > > You would need to use Javascript to extract the value of field1, > field2, > field3, field4, initiated by the Javascript onChange event. > > The HTML codes should look like this: > > > > > > > So the add function snippet that I have: > > function add() > { > var thisform=document.forms[0]; > var field1=thisform.field1.value; > var field2=thisform.field2.value; > var field3=thisform.field3.value; > var field4=thisform.field4.value; > var totalqty=field1+field2+field3+field4; > thisform.totalsum.value=totalqty; > } > > But all I got is a NaN which means Not A Number. I understand that you > solve this by using the parseInt Javascript function. > But still all i get is a NaN value. > > Would appreciate if someone could help me out on this. > > Regards > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Javascript
Hi, In your javascript try field1=Number(thisform.field1.value) etc... Cheers Simon -Original Message- From: Shahmat Dahlan [mailto:[EMAIL PROTECTED]] Sent: 11 October 2002 11:35 To: [EMAIL PROTECTED] Subject: [PHP-DB] Javascript My question might have anything to do with PHP but I have the following scenario: Say I have four fields field1 : field2 : field3 : field4 : And a total sum field, which is a total sum of the value of the expression, totalsum = field1 + field2 + field3 + field4 Total sum : XXX You would need to use Javascript to extract the value of field1, field2, field3, field4, initiated by the Javascript onChange event. The HTML codes should look like this: So the add function snippet that I have: function add() { var thisform=document.forms[0]; var field1=thisform.field1.value; var field2=thisform.field2.value; var field3=thisform.field3.value; var field4=thisform.field4.value; var totalqty=field1+field2+field3+field4; thisform.totalsum.value=totalqty; } But all I got is a NaN which means Not A Number. I understand that you solve this by using the parseInt Javascript function. But still all i get is a NaN value. Would appreciate if someone could help me out on this. Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Javascript
My question might have anything to do with PHP but I have the following scenario: Say I have four fields field1 : field2 : field3 : field4 : And a total sum field, which is a total sum of the value of the expression, totalsum = field1 + field2 + field3 + field4 Total sum : XXX You would need to use Javascript to extract the value of field1, field2, field3, field4, initiated by the Javascript onChange event. The HTML codes should look like this: So the add function snippet that I have: function add() { var thisform=document.forms[0]; var field1=thisform.field1.value; var field2=thisform.field2.value; var field3=thisform.field3.value; var field4=thisform.field4.value; var totalqty=field1+field2+field3+field4; thisform.totalsum.value=totalqty; } But all I got is a NaN which means Not A Number. I understand that you solve this by using the parseInt Javascript function. But still all i get is a NaN value. Would appreciate if someone could help me out on this. Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] javascript problem
thanks for ur solutions. the thing is that if i directly insert this into the html file header it works fine: parent.rightFrame.document.open(); parent.rightFrame.document.write('<html>'); parent.rightFrame.document.write('<head>'); parent.rightFrame.document.write('<link rel="stylesheet" href="../../media/scripts/sidelayout.css" type="text/css" />'); parent.rightFrame.document.write('<link rel="stylesheet" href="../../media/scripts/sidetext.css" type="text/css" />'); parent.rightFrame.document.write('</head>'); parent.rightFrame.document.write('<body>'); parent.rightFrame.document.write('<p>Hello</p>'); parent.rightFrame.document.write('</body>'); parent.rightFrame.document.write('</html>'); parent.rightFrame.document.close(); it works and shows "hello" in there. but when i try to take it out and make a general function, it fails. and the part that fails is the "rightopen()" call. it says that it expects an object. i just don't know what it wants. any ideas? thanks -Original Message- From: Remco Oosten [mailto:[EMAIL PROTECTED]] Sent: March 18, 2002 7:39 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] javascript problem If your framecontainer is your top-document perhaps you can use: top.rightFrame.document.open(); or maybe top.rightFrame.location=''; Remco - Original Message - From: "Josh Trutwin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, March 18, 2002 4:25 PM Subject: Re: [PHP-DB] javascript problem > I am not a JavaScript expert, but I had a similar problem. I THINK that > you need to reference your frames like this: > > window.parent.frames.rightFrame.document.open(); > > Give it a try, hope that helps... > > Josh > > > hi all, > > > > i know this is not exactly the place to ask this, but i don't know > > where else to ask. i'm doing a multiframe project and i'm trying to > > get one of the pages to change the content of another frame when it > > loads. > > > > in the main.htm i have: > > > > > > > > A Global Village? > > ... > > > > <script type="text/javascript"> > > <!-- > > rightopen(); > > rightwrite('Hello', 'www.yahoo.com', 'Yahoo is really good.'); > > rightclose(); > > //--> > > > > > > > > > > > > ... > > > > > > > > the included rightside.js file has the three functions: > > > > function rightopen () { > > parent.rightFrame.document.open(); > > parent.rightFrame.document.write(" > \"-\/\/W3C\/\/DTD > > XHTML 1.0 Strict\/\/EN\""\n); > > parent.rightFrame.document.write(" > > \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">"\n); > > parent.rightFrame.document.write(""\n); > > parent.rightFrame.document.write(""\n); > > parent.rightFrame.document.write("<\/title>"\n); > > parent.rightFrame.document.write(" > content=\"text\/html; charset=iso-8859-1\" \/>"\n); > > parent.rightFrame.document.write(" > href=\"media\/scripts\/sidelayout.css\" type=\"text\/css\" \/>"\n); > > parent.rightFrame.document.write(" > href=\"media\/scripts\/sidetext.css\" type=\"text\/css\" \/>"\n); > > parent.rightFrame.document.write("
Re: [PHP-DB] javascript problem
If your framecontainer is your top-document perhaps you can use: top.rightFrame.document.open(); or maybe top.rightFrame.location=''; Remco - Original Message - From: "Josh Trutwin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, March 18, 2002 4:25 PM Subject: Re: [PHP-DB] javascript problem > I am not a JavaScript expert, but I had a similar problem. I THINK that > you need to reference your frames like this: > > window.parent.frames.rightFrame.document.open(); > > Give it a try, hope that helps... > > Josh > > > hi all, > > > > i know this is not exactly the place to ask this, but i don't know > > where else to ask. i'm doing a multiframe project and i'm trying to > > get one of the pages to change the content of another frame when it > > loads. > > > > in the main.htm i have: > > > > > > > > A Global Village? > > ... > > > > <script type="text/javascript"> > > <!-- > > rightopen(); > > rightwrite('Hello', 'www.yahoo.com', 'Yahoo is really good.'); > > rightclose(); > > //--> > > > > > > > > > > > > ... > > > > > > > > the included rightside.js file has the three functions: > > > > function rightopen () { > > parent.rightFrame.document.open(); > > parent.rightFrame.document.write(" > \"-\/\/W3C\/\/DTD > > XHTML 1.0 Strict\/\/EN\""\n); > > parent.rightFrame.document.write(" > > \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">"\n); > > parent.rightFrame.document.write(""\n); > > parent.rightFrame.document.write(""\n); > > parent.rightFrame.document.write("<\/title>"\n); > > parent.rightFrame.document.write(" > content=\"text\/html; charset=iso-8859-1\" \/>"\n); > > parent.rightFrame.document.write(" > href=\"media\/scripts\/sidelayout.css\" type=\"text\/css\" \/>"\n); > > parent.rightFrame.document.write(" > href=\"media\/scripts\/sidetext.css\" type=\"text\/css\" \/>"\n); > > parent.rightFrame.document.write("
Re: [PHP-DB] javascript problem
I am not a JavaScript expert, but I had a similar problem. I THINK that you need to reference your frames like this: window.parent.frames.rightFrame.document.open(); Give it a try, hope that helps... Josh > hi all, > > i know this is not exactly the place to ask this, but i don't know > where else to ask. i'm doing a multiframe project and i'm trying to > get one of the pages to change the content of another frame when it > loads. > > in the main.htm i have: > > > > A Global Village? > ... > >