SkyRanger Posted April 24, 2007 Share Posted April 24, 2007 I am not looking for somebody to write me a script, if I was then I am posting in the wrong section. What I am looking for though is if anybody knows where I can find a tutorial for either a php or javascript /mysql Address Book script. I figure javascript because I don't think PHP can do this, but if it can, can somebody point me in the right direction. Here is what I am looking for. User clicks on addressbook link. chooses name, auto inserts into To: field. I can already populate the address book from mysql but need to figure out how to get it moved over without having to close the addressbook. Anybody have any ideas? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 ~bump~ Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 Ok, scrapped the popup box move to text box script. Decided to try and figure an easier way to to this. On the same page. I have a list of names: John Jane Bob Marc Chris I want to be able to click on a radio button beside there name and have it automatically insert into a text box? Any ideas? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 Ok, this is what I have so far but it doesn't seem to be working: <script> function insertext(text,area) { if(document.getElementById(name)) { document.name.focus(); document.name.value = document.name.value + " " + text document.name.focus(); } } </script> </head> <body> <form method="post" action="send.php"> bunch of other form entries here... To: <input type="text" name="to_name" size="30"> </form> List of Entries to choose from: <? $resultab = mysql_query( "SELECT * from address where fname='$loggeduser'") or die( "Unable to select database"); $wordnum = mysql_num_rows( $resultab ); while( $rowab = mysql_fetch_array( $resultab ) ) { $toname = $rowab['abname']; echo "<a href=\"#\" onclick=\"javascript: insertext('$toname','to_name');\">".$rowab['abname'].""; echo "<br>"; } ?> I am using FF and IE and it won't work in either. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 24, 2007 Share Posted April 24, 2007 I assume we're just talking about hte JS function? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 I assume so, I know nothing about javascript. What I am trying to do is copy the link info. the info pulled from mysql $toname and insert it into a text box in a form when somebody clicks on the link. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 25, 2007 Author Share Posted April 25, 2007 ~bump~ Quote Link to comment Share on other sites More sharing options...
fenway Posted April 25, 2007 Share Posted April 25, 2007 Well, you're passing two variables, but you have 3 in your function?!?!? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 Decided to go a different root because I couldn't figure the code out. I code php and not javascript but unfortionatly I need it for my script to work. Here is what I came up with so far but still having problems: echo "<input name=\"sendto\" type=\"radio\" id=\"to_name1\" value=\"".$rowab['abname']."\">".$rowab['abname'].""; echo "<br>"; } ?><button onclick="document.getElementById('to_name2').value= document.getElementById('to_name1').value">Add Name</button> <input type="text" name="to_name" id="to_name2" size="30"> The first radio button works in the list,(So when i hit add name it will echo the first radiobutton to the text box) but after that it only echos the first one into the text box. Can anybody give me a hand trying to figure out why? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 26, 2007 Share Posted April 26, 2007 I have no idea what you're trying to do by changing a radio button's value?!? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 Ok, what I need it to do is: If somebody picks the first radio button - sends the value to textbox1 or If somebody picks the second radio button - sends the value to textbox1 etc Quote Link to comment Share on other sites More sharing options...
fenway Posted April 26, 2007 Share Posted April 26, 2007 What's wrong with onclick="this.form.elements['textbox1'].value = this.value"? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 The problem is that it will not choose the second,third, etc, with the code I displayed. It always defaults to the first radio button and echos that value. I know nothing about javascript. I got lucky when I got as far as I did after searching on the net. Quote Link to comment Share on other sites More sharing options...
nogray Posted April 26, 2007 Share Posted April 26, 2007 instead of going back and forward, this will get you started. <script language="javascript"> function fill_name(val){ document.getElementById('to_name2').value = val; } </script> <a href="#" onclick="fill_name('Joe Dirt'); return false;">Joe Dirt</a><br /> <a href="#" onclick="fill_name('Joe Dirt 1'); return false;">Joe Dirt 1</a><br /> <a href="#" onclick="fill_name('Joe Dirt 2'); return false;">Joe Dirt 2</a><br /> <a href="#" onclick="fill_name('Joe Dirt 3'); return false;">Joe Dirt 3</a><br /> <a href="#" onclick="fill_name('Joe Dirt 4'); return false;">Joe Dirt 4</a><br /> <a href="#" onclick="fill_name('Joe Dirt 5'); return false;">Joe Dirt 5</a><br /> <input type="text" name="to_name" id="to_name2" size="30"> Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 OMG, awsome, that is exactly what I needed. With a little modification to read with mysql I got it to work the way I needed it to. Thank you VERY much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.