SieRobin Posted November 8, 2006 Share Posted November 8, 2006 What I'm trying to do is, post something from a Select option, but before they actually submit the application, have it post information into a table, so they can see the description of what they're choosing, is this possible with PHP? Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/ Share on other sites More sharing options...
Orio Posted November 8, 2006 Share Posted November 8, 2006 You need to look into AJAX. I dont know much about it, but it basicly triggers something to run using javascript's onChange/OnClick etc, then it can preform stuff in the background (using PHP for an example) and send the information back to the page and finally change the page dynamiclly using JavaScript.But you can make everything more simple by getting all the information to the page, and then make javascript display the required information when onChange is triggered.Orio Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121686 Share on other sites More sharing options...
SieRobin Posted November 8, 2006 Author Share Posted November 8, 2006 I use Ajax for my chatroom, which just keeps sending calls to the database, so it's a Live chatroom instead of refreshing the page everytime you want to see what was posted.What you're saying is that I can use the onChange feature to actually trigger what will be inserted into the table when they Choose something from the select menu? Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121691 Share on other sites More sharing options...
Orio Posted November 8, 2006 Share Posted November 8, 2006 I say load all the data you that you might want to output into the javascript part and HTML part, and everytime something is selected, dynamicly display it using javascript.[code]<html><head><scrip>function description() { msg = new Array(); msg['1'] = "Description 1"; //populate these using php msg['2'] = "Description of something"; var updiv = document.getElementById("description"); updiv.innerHTML = "Description- "+msg[document.dropdown.drop.selectedIndex];}</scrip></head><body><FORM name="dropdown"> <SELECT name="drop" onChange="javascript:description();"><OPTION SELECTED>-------<OPTION value="1">Prod 1 <!-- populate these using php --><OPTION value="2">Prod 2 </SELECT> </FORM> <div id="description"></div></form></body></html>[/code]** Note- I changed the script tag to <scrip> because SMF doesnt like it.Orio. Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121709 Share on other sites More sharing options...
SieRobin Posted November 8, 2006 Author Share Posted November 8, 2006 Stupid question lol, I forget how to pass a Javascript variable into HTML. :x Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121716 Share on other sites More sharing options...
Orio Posted November 8, 2006 Share Posted November 8, 2006 What do you mean?Orio. Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121717 Share on other sites More sharing options...
SieRobin Posted November 8, 2006 Author Share Posted November 8, 2006 Posting a javascript variable into HTML so I can show the description in the designated area. Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121719 Share on other sites More sharing options...
Orio Posted November 8, 2006 Share Posted November 8, 2006 Look at the script I attached.*This is becoming more of a Javascript topic. Maybe you should post in the JS forum if you need further help doing with that? I have very basic Javascript knowledge, if you need help with the php part I have no problem :)Orio. Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121722 Share on other sites More sharing options...
SieRobin Posted November 8, 2006 Author Share Posted November 8, 2006 Haha, yeah sorry.. I thought it could be accomplished with PHP, rather than JS.. looks like everytime I'm in a rut, someone tells me to resort to JS :P Link to comment https://forums.phpfreaks.com/topic/26603-select-and-post/#findComment-121731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.