Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Eureka! After dumping my generated html page to an editor I saw that someone (php? js?) was inserting error messages (<a .....> even) into my html and that was causing a lot of trouble apparently. I massaged my code and this now does what I expect. echo '<script type="text/javascript">'; ?> var jsgolfers = ["<?php echo implode("\",\"",$golfers); ?>"]; <?php echo 'function gn(str)'; echo '{'; echo 'alert(jsgolfers[str]);'; echo '}'; echo '</script>'; Basically - the $golfers array is built using php and sql early in my script. then the js creates a global array and loads it from $golfers. Then my onclick attribute on a d/e field calls the function which properly displays the corresponding golfer depending upon the input I entered.
  2. And Yes - I have tried using a reference to $jsgolfers as well as just plain jsgolfers.
  3. Been reading all afternoon. Here is where I am at with ONE big error. Everytime I call the function 'gn(n)' I get the message that "jsgolfers is undefined'. echo '<script type="text/javascript">'; echo 'var jsgolfers = new array["<?php echo join(":\", $golfers); ?>"];'; echo '</script>'; echo '<script type="text/javascript">'; echo 'function gn(str)'; echo '{'; echo 'alert(jsgolfers[$str]);'; echo '}'; echo '</script>'; First - the $golfers array is created and has values which I've displayed on my page I've had a lot of difficulty with the join function - the example I found on the web didn't work so I've whittled it down to what it is. Will appreciate any pointers one can provide. Supposedly this code will take a php-produced array var and build a JS array var for me to use in an onclick event on my page.
  4. Please disregard my post. It dawned on me (once again) that I've made a major mistake in my solution by trying to combine php session vars with js execution. I'll get it down pat one of these days. That said (admitted!) - how would a decent js programmer tackle this problem. d/e form to collect a series of picks from the user. The form should do an immediate display of the associated "names" of the picked items (numbers). There are 12 entries to be made on the form so whatever solution is developed has to be executed 12 times on each form. I had considered doing queries for each change but thought that inefficient, hence my original idea of a session array (which won't work). Can js develop an array (once) to then be used in a js function call that will happen multiple times?
  5. I have a d/e form that has a series of numbered fields - Player1,Player2,Player3... followed by another series - Playername1,Playername2,Playername3... They are related by number naturally. What I want to do is use js to populate the corresponding Playername field when its 'partner' Player field has been modified. So far I've figured that in the html input tag for 'Playern' I would have an 'onchange="gn($i)"' where 'gn($i)' is the function that will pull my name values from a session array i've already built. My question is - how do I post the looked up value to the name field? here is my proposed function header: echo '<script type="text/javascript">'; echo 'function gn(str)'; echo '{'; this is where the lookup to my session array would occur and the posting of the result to my name field. echo '}'; echo '</script>'; here are my current input tags echo '<td><input onchange="gn($i)" type="text" name="Player'.$i.'" tabindex="1'.$i.'" size="4" maxlength="2" value="'.$_POST["Player$i"].'"></td>'; echo '<td><input '.$n_attr.' id="pad" type="text" name="Player'.$i.'" size="25" maxlength="25" value="'.$_POST["Playername$i"].'"></td>'; The input tags are in a for loop controlled by $i. So for any given 'player(n)' field I want to look up in my array for element (n) and then post the array's (n) value to the input tag called 'Playername(n)'. Is this easily doable?
  6. ok - I see the concept of burying an anchor in my td. Thanks!
  7. Now that I've discovered that the HTML TABLE element doesn't support a name attribute or a tabindex one, and neither do the TR or TD elements I'm wondering if JS can come to my rescue. I'm new to it and don't find anything so far on this feature I've used simple xx.xx.focus statements in onclick events or onload events, but since I can't set a name attribute on a table or td element, I can't do that here. Any possibilities here?
  8. I've never 'called' a function before, just used it as the target of an event ie, onclick="functionname". I'm trying to do so in a little test php script to try out some stuff I got out of Resig's book. in the html head section i have my script tag and the function in the body i have some echo statements trying to output the results of a call to the function echo 'paragraph contains'.getText("p1"); I get an undefined function error when I run this. Is there some special syntax for 'calling' a js function? I can't seem to find anything in the book on this.
  9. Everything I know about the web is from w3schools!!! Without that there is nothingness! where would you suggest I get my nourishment - for js at least?
  10. Found it. The field I was trying to set I hadn't put an ID attribute on. The only one missing it!
  11. wouldn't it help if you told us what it wasn't doing anymore?
  12. ok - nobody seems to know much about js on the iphone - errors that is. So - in the meantime I've been experimenting and come up with this so far. function CopyResult() { var x=document.getElementById("curdirs").value; try { 1 var str = x; 2 var arstr = str.split(" "); 3 if (arstr.length >1) { 4 document.getElementById("mntstsy").checked = true; } 5 else { 6 document.getElementById("mntstsn").checked = true; } 7 str = arstr.shift(); 8 alert("shift done- now using: "+str); 9 document.getElementById("uid").value =str; 10 alert("set uid"); This function is called from an html "select" tag using the onchange event. I've tried several alerts in the function and find that I'm getting thru it up until I try to set the "uid" input tag in line 9 with the value in the var "str". The alert following this line doesn't get executed. I do know that I have values that are good as I've seen them using alerts, and I can see that the actions performed by lines 4 or 6 get performed. But then it dies giving me an error message of "undefined". Does anyone have a clue why line 9 fails on safari (iphone) and runs just fine on IE?
  13. I've read the rules and the help but I don't see how it's done. No buttons on any screens. If I get the solution or figure it out in the meantime, I'd like to mark the post solved.
  14. OK - here is a function I made (cut and pasted essentially) that works great on my laptop. But on my iphone it gives me an error. The error is vague - err.description reports as: "undefined". Here's the code, which as I said works great on ie. Basically it grabs the selected item from a dropdown menu ("curdirs") and copies it (after a little cleanup) onto some other input fields. <script type="text/javascript"> function displayResult() { var x=document.getElementById("curdirs").selectedIndex; var y=document.getElementById("curdirs").options; try { var str = y[x].text; var arstr = str.split(" "); if (arstr.length >1) document.getElementById("mntstsy").checked = true; else document.getElementById("mntstsn").checked = true; str = arstr.shift(); document.getElementById("uid").value =str; document.getElementById("dirstsy").checked = true; document.getElementById("dirstsy").focus(); } catch(err) { txt="There was an error on this page.\n\n"; txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } The code gets triggered by the onclick event. I've tried onchange, onblur for the iphone becuase of some posts I read, but all that does is eliminate the error popup - it still doesn't do anything on the iphone. Yes - I have read about the lack of support for the "select" tag on Safari, but I'm hoping someone has this a clue why this js doesn't work. I certainly don't - I have all of 3 days of experience in it!
  15. I just came back online to post that I had solved this - only to see the very first response telling me the same thing. The code was all lifted from a posting I found online, so it wasn't my fault. I did finally see it though after doing some reading on how classes worked. Thanks for the quick response tho!
  16. ok - I lifted some code to help identify the client's browser (damn iphone doesn't like my "select" tag). The code was this class definition and was followed by a couple lines showing how to use it. Here are the two lines: $browser = new Browser ; echo "Using: $Browser->Name $Browser->Version" ; When I include the class and add these two lines to my script all I get is the word "using:' displayed. Is it possible that the writer of this code left something out? I don't know what the syntax of the "x->y" references are, but shouldnt' there be a call to functions within the class?
  17. sorry - just joined this forum for some js help and now, with my php problem, I just slipped up. :(
  18. Can anyone explain this? Warning: get_browser() [function.get-browser]: browscap ini directive not set in /home/albany/public_html/players_dir/dirupdate.php on ..... I'm trying to determine the browser so I can juggle my html a little bit.
  19. Eureka! Solved it after reviewin about 4 pages of this forum's posts and discovering some different properties to experiment with. Here's the function that works (it takes a choice from a dropdown menu and places it in a type="text" field). function displayResult() { var x=document.getElementById("curdirs").selectedIndex; var y=document.getElementById("curdirs").options; try { document.getElementById("uid").value =y[x].text; } catch(err) { txt="There was an error on this page.\n\n"; txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } Now it's on to placing the cursor into the next field.
  20. I'm new to php and js but have been pgming for 30+ years so I kinda know what I'm doing. I'm also new to this forum. I've got an html page that my PHP code built for me - two divs in play here. One contains a <form> with some fields, the other has a <select> list of text lines (<option>) which I want to let the user scroll thru and click on one of them and have that text copied to one of the <input> objects in the other div. Pretty simple huh? Here's the PHP line that created the html code in the <select> object: echo '<select id="curdirs" onclick="displayResult()" size="8">'; This is followed with a loop that puts out several <option> elements from a query. This is all good and works for me. The js function is : <script type="text/javascript"> function displayResult() { var x=document.getElementById("curdirs").selectedIndex; var y=document.getElementById("curdirs").options; alert("selected "+ y[x].text); try { document.getElementById("thisform.uid").innerHTML=y[x].text; } catch(err) { txt="There was an error on this page.\n\n"; txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } </script> The function correctly grabs the selected index number from the click in the drop-down; it correctly determines the text value that was selected by the user; these I see in the first alert command. Good so far. The function fails when I try to place the selected text into my <input> field. I've tinkered with this command by appending the <form> name to the <input> name, but neither way works. Same error. The second alert displays the text and includes the following as a result of the call to "err.description": 'document.getElementById(...)' is null or not an object. Now - I lifted this Js code from a tutorial online and thought I could make it do what I wanted. Apparently there's more to placing some text into an <input> than I'm aware of. Can someone point me in the right direction?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.