Image as an input

Discussion in 'Programming' started by timelf123, Jul 24, 2007.

  1. #1
    I need to find a viable solution for using an image as an input. The catch is, it has to be in a scroller that is user operated. I have that code, but I need to find out how to set a radio button when that particular image is selected. A javascript onclick perhaps?


    Any thoughts are appreciated,

    Tim
     
    timelf123, Jul 24, 2007 IP
  2. ProgrammersTalk

    ProgrammersTalk Peon

    Messages:
    684
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    sorry, can you please describe more about what program are you planning to create? and what language?
     
    ProgrammersTalk, Jul 24, 2007 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As above, dont get what you are trying to achive? Are you trying to get users to click an image (eg - chose your favourit image?) Are there any other inputs on the page or is it simply clicking on one image?
     
    AstarothSolutions, Jul 25, 2007 IP
  4. rps111

    rps111 Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do you want the person to select an image from the image gallery?
     
    rps111, Jul 25, 2007 IP
  5. timelf123

    timelf123 Peon

    Messages:
    897
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry. Php, javascript and HTML are what I have to use.

    It should work like this:
    
     <-|| Image1 | Image 2... ||->
       ||    o   |     o      ||
    
    Code (markup):
    What will happen is each image should be somehow linked to the radio button below it. You can scroll through, select what image you want, click it, and it will fill the radio button for you. If possible, I would like to eliminate the radio button altogether, and make it so once you click the image, it sets a hidden value, ready to be posted to a form.

    Is this even possible?
     
    timelf123, Jul 25, 2007 IP
  6. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It would be easier to have a hidden field and assign its value using javascript with an onclick function on the images based on the image clicked.
     
    AstarothSolutions, Jul 25, 2007 IP
  7. timelf123

    timelf123 Peon

    Messages:
    897
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #7
    How would I go about assigning its value? Onclick of image, getelementid of radio box?

    Here is my current code (smarty):
    
    <td align="center">
                        {assign var="prizedesc" value=$prize->description|nl2br}
    										{assign var="prizedesc" value=$prizedesc|escape:"javascript"}
    										<img src="{$prize->imgurl}" onMouseOver="return escape('{$prizedesc}');"><br>
                        <b>{$prize->name}</b><br>
                        {if $for_points}
    											({$prize->points_required} Point{if $prize->points_required != 1}s{/if})<br>
    										{elseif $is_cash}
    											${$prize->cash_required} Minimum<br>
    										{else}
    											({$prize->referrals_required} Referral{if $prize->referrals_required != 1}s{/if})<br>
    										{/if}
                        {if $first == "true"}
                            <input type="radio" name="prizeid" value="{$prize->id}"  checked>
                            {assign var="first" value="false"}
                        {else}
    						{if $selected_prize == $prize->id}
                            	<input type="radio" name="prizeid" value="{$prize->id}"  checked>
    						{else}
    							<input type="radio" name="prizeid" value="{$prize->id}">
    						{/if}
    
    Code (markup):
     
    timelf123, Jul 25, 2007 IP