Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Simple Javascript request from a non-programmer.

  • 15-06-2008 1:27pm
    #1
    Closed Accounts Posts: 1,650 ✭✭✭


    This will be used locally, not on the internet. Using IE6/7 only.

    What I want to do is provide several combo boxes containing several options across the top of web page. As a selection is made from each combo, several blocks of information are displayed underneath in tabular fashion, probably in text boxes I think. A single column for each combo box selection results.

    The purpose of this is to compare the information side by side.

    So, it's:

    If comboboxA=option4 then textboxA1=first piece of associated text and textboxA2=next piece of associated text and textboxA3=next piece of associated text etc. etc. Same for comboboxB,comboboxC etc.

    Would it be possible to store the text in a text file to be read into the relevant text boxes? This would be nice, as the text to be displayed would change from time to time, but not really necessary.

    I don't know any syntax at all!!

    Thanks.

    EDIT: uploaded mockup.

    attachment.php?attachmentid=57936&d=1213538850.


Comments

  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    What platform are you running on? If your using ASP.NET just look at using an update panel around your table and do a auto postback on the onselectedindexchanged event and update your table then.

    Or you could hard code all the pieces of text into jscript variables on the page and then use these to update your table.


  • Closed Accounts Posts: 1,650 ✭✭✭shayser


    Thanks kayos. You suggestion is a bit over my head though, sorry. My original post might be a bit more complicated that it should be.

    In one sentence, I want to populate several text boxes with text after an option from a combo box has been selected.

    If combobox selection = item 4 in the list then use this text.
    If combobox selection = item 7 in the list then user this other text.
    etc.


    Thanks.


  • Registered Users, Registered Users 2 Posts: 919 ✭✭✭timeout


    If you are not too much into programming could I make the suggestion of trying this in excel. Excel allows you to set what text should appear in a relevent cell depending on the condition of another. As well as not needing internet access you could send it to people if needed.


  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    What platform are you running on? Is it ASP.NET or php or just straight HTML etc

    Honestly your asking for an answer without giving enough information to allow us to give you the correct one. There are a load of different ways of doing this and the best or easy ways all depend on what technology you are using.


  • Closed Accounts Posts: 1,650 ✭✭✭shayser


    Thanks timeout. In Excel I managed to use Fn to check the value of drop down list and put some text in another field based on the value. So progress! :)

    kayos, it's just javascript/html/notepad. I thought of Javascript because I actually did a bit of this, but this was 11 years ago. (A quotation script for an insurance company website that I thought was quite good!). Thought it might come back to me one I got started, but it's gone!


  • Advertisement
  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    Even as an asp.net developer I recommend staying away from the update panel unless you want to become part of whats choking websites these days - i.e. overkill.

    You need to get some basics down on javascript. I'm fairly sure theres a general rule here that you should research and attempt problems yourself and if you can't get it to work ask your questions here. Asking for a complete solution is a bit much.

    Since we don't know what you know I'll mention the basics.

    Find and element on the page - document.getElementById(elementid).
    So if your select has an id of select1 you would find it with document.getElementById('select1').

    Capture a selection in a select element:-

    var sel = document.getElementById('select1');
    sel.onchange = select1Changed;

    function select1Changed() {
    //do something
    }

    Reference the select that caused the event:-

    function select1Changed() {
    var seltext = this.options[this.selectedIndex].text;
    }

    Set the value of a input element (textbox):-

    function select1Changed() {
    var seltext = this.options[this.selectedIndex].text;
    var tb = document.getElementById('input1');
    tb.value = seltext;
    }

    These are just examples to get you going. The other side of javascript that must be considered in my opinion is what you want to do if the user doesn't have scripting enabled. Not a huge issue but ironically more and more so because of the increasing use of script itself. I turn it off myself on some sites because they have their own pages crippled with it. Try turning it off here (firefox web developer toolbar) for example and experience a speed rush. This is where unobtrusive javascript comes in. The standard answer I get these days when I suggest unobtrusive scripting is "well I want to get the basics down first before I try that". Well start learning the right way first imo.


Advertisement